Live location tracking and playback for the game "manhunt"
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Use ServerState::get_room_open instead of dupe

Ben C 6a4906d9 646f797f

+4 -10
+4 -10
manhunt-signaling/main.rs
··· 67 67 .insert(origin, code.clone()); 68 68 } 69 69 70 - pub fn room_is_open(&self, room_id: RoomId) -> bool { 70 + pub fn room_is_open(&self, room_id: &RoomId) -> bool { 71 71 self.matches 72 72 .lock() 73 73 .unwrap() 74 - .get(&room_id) 74 + .get(room_id) 75 75 .is_some_and(|m| m.open_lobby) 76 76 } 77 77 ··· 98 98 99 99 /// Try to join a room by a code, returns `true` if successful 100 100 pub fn try_join_room(&mut self, origin: SocketAddr, code: RoomId) -> bool { 101 - if self 102 - .matches 103 - .lock() 104 - .unwrap() 105 - .get(&code) 106 - .is_some_and(|m| m.open_lobby) 107 - { 101 + if self.room_is_open(&code) { 108 102 self.waiting_clients.lock().unwrap().insert(origin, code); 109 103 true 110 104 } else { ··· 306 300 .route( 307 301 "/room_exists/{id}", 308 302 get(move |Path(room_id): Path<String>| async move { 309 - if state.room_is_open(room_id) { 303 + if state.room_is_open(&room_id) { 310 304 StatusCode::OK 311 305 } else { 312 306 StatusCode::NOT_FOUND