File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -309,7 +309,7 @@ async fn handle_authenticated_connection(
309309 }
310310
311311 // client disconnected gracefully
312- handle_disconnect ( state, peer) . await ;
312+ handle_disconnect ( state, & mut peer) . await ;
313313
314314 Ok ( ( ) )
315315}
@@ -463,19 +463,14 @@ async fn handle_message(
463463 }
464464}
465465
466- async fn handle_disconnect ( state : Arc < Mutex < Shared > > , peer : Peer ) {
466+ async fn handle_disconnect ( state : Arc < Mutex < Shared > > , peer : & mut Peer ) {
467+ // remove them from the room cleanly and notify others
468+ leave_room ( state. clone ( ) , peer) . await ;
469+
470+ // remove name from the map
467471 let mut state = state. lock ( ) . await ;
468472 state. names . remove ( & peer. id ) ;
469- let names = state. names . clone ( ) ;
470-
471- if let Some ( room_id) = peer. room_id {
472- let room = state. rooms . get_mut ( & room_id) . unwrap ( ) ;
473-
474- room. peers . remove ( & peer. id ) ;
475-
476- let msg = room. connected_users_info ( names) ;
477- room. broadcast ( & msg) . await ;
478- }
479473
480- // TODO: notify waiting peers of new room list
474+ // remove handle
475+ state. waiting_peers . remove ( & peer. id ) ;
481476}
You can’t perform that action at this time.
0 commit comments