Delete room when no participants are left
This commit is contained in:
parent
9cf39b1da6
commit
48a1dd1588
5 changed files with 13 additions and 2 deletions
|
@ -890,11 +890,16 @@ impl Server {
|
|||
) -> impl Future<Output = Result<()>> {
|
||||
let client = self.app_state.live_kit_client.clone();
|
||||
let room_name = room.live_kit_room.clone();
|
||||
let participant_count = room.participants.len();
|
||||
async move {
|
||||
if let Some(client) = client {
|
||||
client
|
||||
.remove_participant(room_name, connection_id.to_string())
|
||||
.remove_participant(room_name.clone(), connection_id.to_string())
|
||||
.await?;
|
||||
|
||||
if participant_count == 0 {
|
||||
client.delete_room(room_name).await?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -495,7 +495,7 @@ impl Store {
|
|||
}
|
||||
});
|
||||
|
||||
let room = if room.participants.is_empty() && room.pending_participant_user_ids.is_empty() {
|
||||
let room = if room.participants.is_empty() {
|
||||
Cow::Owned(self.rooms.remove(&room_id).unwrap())
|
||||
} else {
|
||||
Cow::Borrowed(self.rooms.get(&room_id).unwrap())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue