-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
livekit-rtc: set room state to disconnected on dc #223
base: main
Are you sure you want to change the base?
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the issue is different here. The FfiServer is sending ConnectionStateChanged before it successfully closes the room.
You may not notice this because it's not waiting for the DisconnectCallback, unlike what the python-sdks is doing.
aha, i see. i'll change it so that event gets properly processed before the await resolves |
diff --git a/packages/livekit-rtc/src/room.ts b/packages/livekit-rtc/src/room.ts
index 95f19ff..f9bebeb 100644
--- a/packages/livekit-rtc/src/room.ts
+++ b/packages/livekit-rtc/src/room.ts
@@ -148,7 +149,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: {
@@ -157,9 +158,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;
+ });
+
FfiClient.instance.removeAllListeners();
this.removeAllListeners();
- this.connectionState = ConnectionState.CONN_DISCONNECTED;
}
private onFfiEvent = (ffiEvent: FfiEvent) => { this doesn't work, for some reason. neither |
Mmh seems like an issue on the Rust side then? |
looked into it a bit more, the |
sometimes it works? there's a race condition somewhere in here. |
this is working now: the room state is set to disconnected manually, regardless of whether the |
while trying to reproduce another bug i found this:
room.disconnect()
does not set the room state to disconnected.