fix(voice): add reconnect/disconnect event handlers + connection quality logging
This commit is contained in:
+26
-1
@@ -174,7 +174,8 @@ export const useVoiceStore = create<VoiceState>((set, get) => ({
|
||||
syncParticipants();
|
||||
});
|
||||
|
||||
room.on(RoomEvent.Disconnected, () => {
|
||||
room.on(RoomEvent.Disconnected, (reason?: any) => {
|
||||
console.warn('[voice] disconnected, reason:', reason);
|
||||
set({
|
||||
isConnected: false,
|
||||
currentRoom: null,
|
||||
@@ -187,6 +188,30 @@ export const useVoiceStore = create<VoiceState>((set, get) => ({
|
||||
});
|
||||
});
|
||||
|
||||
room.on(RoomEvent.Reconnecting, () => {
|
||||
console.warn('[voice] reconnecting to LiveKit...');
|
||||
set({ error: 'Reconnecting...' });
|
||||
});
|
||||
|
||||
room.on(RoomEvent.Reconnected, () => {
|
||||
console.log('[voice] reconnected to LiveKit');
|
||||
set({ error: null });
|
||||
syncParticipants();
|
||||
});
|
||||
|
||||
room.on(RoomEvent.SignalConnected, () => {
|
||||
console.log('[voice] signal channel connected');
|
||||
});
|
||||
|
||||
room.on(RoomEvent.ConnectionQualityChanged, (_quality: any, participant: Participant) => {
|
||||
if (participant.identity === room.localParticipant.identity) {
|
||||
// if quality drops to poor, log it
|
||||
if (_quality === 'poor') {
|
||||
console.warn('[voice] poor connection quality');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
room.on(RoomEvent.ParticipantConnected, () => {
|
||||
syncParticipants();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user