From 91259369b2b87eb647e9743c874d7e58894149c1 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Sat, 27 Jan 2024 19:59:39 +0100 Subject: handle room joins without page reload. --- server/src/logic.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'server') diff --git a/server/src/logic.rs b/server/src/logic.rs index 01b7a82..b16e605 100644 --- a/server/src/logic.rs +++ b/server/src/logic.rs @@ -106,10 +106,9 @@ impl State { ServerboundPacket::Join { hash } => { if let Some(room) = &cstate.current_room { room.leave(self, client).await; - // TODO dont leak room - // if room.should_remove().await { - // self.rooms.write().await.remove(üw); - // } + if room.should_remove().await { + self.rooms.write().await.remove(&room.hash); + } } if let Some(hash) = hash { let room = self @@ -223,10 +222,8 @@ impl Room { pub async fn leave(&self, state: &State, client: Client) { debug!("client leave {client:?}"); for c in self.users.read().await.iter() { - if *c != client { - self.send_to_client(*c, ClientboundPacket::ClientLeave { id: client }) - .await; - } + self.send_to_client(*c, ClientboundPacket::ClientLeave { id: client }) + .await; } let user_count = { let mut g = self.users.write().await; -- cgit v1.2.3-70-g09d2