Skip to content

Commit

Permalink
livekit-rtc: set room state to disconnected on dc
Browse files Browse the repository at this point in the history
  • Loading branch information
nbsp committed Jul 19, 2024
1 parent 3b40e58 commit 5dabd53
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/livekit-rtc/src/room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import type {
ConnectResponse,
ConnectionQuality,
DataPacketKind,
DisconnectCallback,
DisconnectResponse,
IceServer,
RoomInfo,
Expand Down Expand Up @@ -149,7 +150,7 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
return;
}

FfiClient.instance.request<DisconnectResponse>({
const res = FfiClient.instance.request<DisconnectResponse>({
message: {
case: 'disconnect',
value: {
Expand All @@ -158,6 +159,12 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
},
});

await FfiClient.instance.waitFor<DisconnectCallback>((ev: FfiEvent) => {
return ev.message.case == 'disconnect' && ev.message.value.asyncId == res.asyncId;
});

this.connectionState = ConnectionState.CONN_DISCONNECTED;

FfiClient.instance.removeListener(FfiClientEvent.FfiEvent, this.onFfiEvent);
this.removeAllListeners();
}
Expand Down

0 comments on commit 5dabd53

Please sign in to comment.