mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-25 01:34:02 +00:00
Disconnect from live-kit Room
on drop
This commit is contained in:
parent
47be340cac
commit
9cf39b1da6
3 changed files with 19 additions and 2 deletions
|
@ -50,7 +50,9 @@ impl Entity for Room {
|
|||
type Event = Event;
|
||||
|
||||
fn release(&mut self, _: &mut MutableAppContext) {
|
||||
self.client.send(proto::LeaveRoom { id: self.id }).log_err();
|
||||
if self.status.is_online() {
|
||||
self.client.send(proto::LeaveRoom { id: self.id }).log_err();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -210,6 +212,7 @@ impl Room {
|
|||
self.pending_participants.clear();
|
||||
self.participant_user_ids.clear();
|
||||
self.subscriptions.clear();
|
||||
self.live_kit_room.take();
|
||||
self.client.send(proto::LeaveRoom { id: self.id })?;
|
||||
Ok(())
|
||||
}
|
||||
|
@ -630,4 +633,8 @@ impl RoomStatus {
|
|||
pub fn is_offline(&self) -> bool {
|
||||
matches!(self, RoomStatus::Offline)
|
||||
}
|
||||
|
||||
pub fn is_online(&self) -> bool {
|
||||
matches!(self, RoomStatus::Online)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,6 +83,12 @@ public func LKRoomConnect(room: UnsafeRawPointer, url: CFString, token: CFString
|
|||
}
|
||||
}
|
||||
|
||||
@_cdecl("LKRoomDisconnect")
|
||||
public func LKRoomDisconnect(room: UnsafeRawPointer) {
|
||||
let room = Unmanaged<Room>.fromOpaque(room).takeUnretainedValue()
|
||||
room.disconnect()
|
||||
}
|
||||
|
||||
@_cdecl("LKRoomPublishVideoTrack")
|
||||
public func LKRoomPublishVideoTrack(room: UnsafeRawPointer, track: UnsafeRawPointer, callback: @escaping @convention(c) (UnsafeRawPointer, CFString?) -> Void, callback_data: UnsafeRawPointer) {
|
||||
let room = Unmanaged<Room>.fromOpaque(room).takeUnretainedValue()
|
||||
|
|
|
@ -43,6 +43,7 @@ extern "C" {
|
|||
callback: extern "C" fn(*mut c_void, CFStringRef),
|
||||
callback_data: *mut c_void,
|
||||
);
|
||||
fn LKRoomDisconnect(room: *const c_void);
|
||||
fn LKRoomPublishVideoTrack(
|
||||
room: *const c_void,
|
||||
track: *const c_void,
|
||||
|
@ -195,7 +196,10 @@ impl Room {
|
|||
|
||||
impl Drop for Room {
|
||||
fn drop(&mut self) {
|
||||
unsafe { LKRelease(self.native_room) }
|
||||
unsafe {
|
||||
LKRoomDisconnect(self.native_room);
|
||||
LKRelease(self.native_room);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue