feat: improve WebRTC connection state handling and enhance WebSocket connection logic

This commit is contained in:
Marco Beretta 2025-04-05 12:30:11 +02:00
parent 2eda62cf67
commit bf753bb5dd
No known key found for this signature in database
GPG key ID: D918033D8E74CC11
2 changed files with 17 additions and 8 deletions

View file

@ -69,9 +69,8 @@ class WebRTCConnection {
const state = this.peerConnection.connectionState;
logger.info(`Connection state changed to ${state}`);
this.state = state;
if (state === 'failed' || state === 'closed') {
if (state === 'failed' || state === 'closed' || state === 'disconnected') {
this.cleanup();
}
};
@ -148,8 +147,8 @@ class AudioHandler {
rtcConnection.addIceCandidate(candidate);
});
socket.on('vad-status', (status) => {
logger.debug(`VAD status from ${socket.id}: ${JSON.stringify(status)}`);
socket.on('vad-status', (speaking) => {
logger.debug(`VAD status from ${socket.id}: ${JSON.stringify(speaking)}`);
});
socket.on('disconnect', () => {