summaryrefslogtreecommitdiff
path: root/src/conn.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/conn.rs')
-rw-r--r--src/conn.rs13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/conn.rs b/src/conn.rs
index 01bc1e8..9c23592 100644
--- a/src/conn.rs
+++ b/src/conn.rs
@@ -72,13 +72,16 @@ pub async fn lobby(socket: WebSocket, addr: SocketAddr, room: Arc<RwLock<Room>>)
let room_lock = room.read().await;
let mut players = room_lock.players.write().await;
- let disconn_p = players.remove(&addr);
- for p in players.values() {
- if let Err(e) = p.conn.tx.send(Message::text("logoff {disconn_p.seqid} {disconn_p.name}")) {
- println!("couldn't deliver logoff info to {}: {}", p, e);
+ if let Some(disconn_p) = players.remove(&addr) {
+ for p in players.values() {
+ if let Err(e) = p.conn.tx.send(Message::text(format!("logoff {}", disconn_p.uid))) {
+ println!("couldn't deliver logoff info to {}: {}", p, e);
+ }
}
+ println!("{disconn_p} disconnected");
+ } else {
+ println!("{addr} disconnected");
}
- println!("{} disconnected", if let Some(p) = disconn_p { p.to_string() } else { addr.to_string() });
}
pub async fn handle_room(mut incoming: SplitStream<WebSocket>, addr: SocketAddr, room: Arc<RwLock<Room>>) {