diff options
author | metamuffin <metamuffin@disroot.org> | 2024-06-04 23:38:11 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-06-04 23:38:11 +0200 |
commit | 8af2bd377308d877f068e917554c9d8a7c5b2dc1 (patch) | |
tree | b08b53d54c523c116374cc93b84368ae9c948ee0 | |
parent | 61a31c3688347617ebdd125075172fe30d530515 (diff) | |
download | gpn-tron-rust-8af2bd377308d877f068e917554c9d8a7c5b2dc1.tar gpn-tron-rust-8af2bd377308d877f068e917554c9d8a7c5b2dc1.tar.bz2 gpn-tron-rust-8af2bd377308d877f068e917554c9d8a7c5b2dc1.tar.zst |
send chat author
-rw-r--r-- | src/game/server.rs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/game/server.rs b/src/game/server.rs index 79fca1a..1f5cc7b 100644 --- a/src/game/server.rs +++ b/src/game/server.rs @@ -56,12 +56,14 @@ async fn game_loop(config: Config, state: Arc<State>) { struct ClientState { pid: Option<u32>, alive: bool, + username: String, } async fn handle_client(sock: TcpStream, state: Arc<State>) -> Result<()> { let mut cstate = ClientState { pid: None, alive: false, + username: "guest".to_string(), }; let res = handle_client_inner(sock, &state, &mut cstate).await; if let Some(pid) = cstate.pid { @@ -233,7 +235,7 @@ async fn handle_packet( .await?; return Ok(()); } - let _ = state.chat.send(("".to_string(), message)); + let _ = state.chat.send((cstate.username.clone(), message)); } _ => { tx.send_packet(Packet::Error("clients dont send this packet".to_string())) |