import React from 'react'; import { useRecoilState } from 'recoil'; import { Phone, PhoneOff } from 'lucide-react'; import { OGDialog, OGDialogContent, Button } from '~/components'; import { useWebSocket, useCall } from '~/hooks'; import store from '~/store'; export const Call: React.FC = () => { const { isConnected, sendMessage } = useWebSocket(); const { isCalling, isProcessing, startCall, hangUp } = useCall(); const [open, setOpen] = useRecoilState(store.callDialogOpen(0)); const [eventLog, setEventLog] = React.useState([]); const logEvent = (message: string) => { console.log(message); setEventLog((prev) => [...prev, message]); }; React.useEffect(() => { if (isConnected) { logEvent('Connected to server.'); } else { logEvent('Disconnected from server.'); } }, [isConnected]); React.useEffect(() => { if (isCalling) { logEvent('Call started.'); } else if (isProcessing) { logEvent('Processing audio...'); } else { logEvent('Call ended.'); } }, [isCalling, isProcessing]); const handleStartCall = () => { logEvent('Attempting to start call...'); startCall(); }; const handleHangUp = () => { logEvent('Attempting to hang up call...'); hangUp(); }; return (
{isConnected ? 'Connected' : 'Disconnected'}
{isCalling ? ( ) : ( )} {/* Debugging Information */}

Event Log

    {eventLog.map((log, index) => (
  • {log}
  • ))}
); };