livekit_signaller: Improved shutdown behavior

Without sending a Leave request to the server before disconnecting, the
disconnected client will appear present and stuck in the room for a little
while until the server removes it due to inactivity.

After this change, the disconnecting client will immediately leave the room.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1482>
This commit is contained in:
Jordan Yelloz 2024-02-28 09:13:12 -07:00
parent 9c590f4223
commit 002dc36ab9

View file

@ -516,6 +516,17 @@ impl Signaller {
}
}
}
async fn close_signal_client(signal_client: &signal_client::SignalClient) {
signal_client
.send(proto::signal_request::Message::Leave(proto::LeaveRequest {
can_reconnect: false,
reason: proto::DisconnectReason::ClientInitiated as i32,
..Default::default()
}))
.await;
signal_client.close().await;
}
}
impl SignallableImpl for Signaller {
@ -745,7 +756,7 @@ impl SignallableImpl for Signaller {
if let Some(connection) = self.connection.lock().unwrap().take() {
block_on(connection.signal_task).unwrap();
block_on(connection.signal_client.close());
block_on(Self::close_signal_client(&connection.signal_client));
}
}