From 429ab216700a1946c4a8fa043c5366c4c08cfff1 Mon Sep 17 00:00:00 2001 From: szymon Date: Sun, 16 Aug 2026 18:32:36 +0200 Subject: [PATCH] fix: not sending rejection message --- src/network/server.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/network/server.rs b/src/network/server.rs index f44ce54..00328fd 100644 --- a/src/network/server.rs +++ b/src/network/server.rs @@ -137,8 +137,19 @@ impl Server { self.connections.insert(addr, sender); self.request_handshake(addr).await; } else { - let msg = Message::new(ServerMessage::DeclineHandshake { reason: "There is currently game going and it doesn't allow spectators".to_string() }); - self.send_message(addr, msg).await; + let reason = "There is currently game going and it doesn't allow spectators".to_string(); + info!("Rejecting {}, because {}", addr, reason); + + let msg = Message::new(ServerMessage::DeclineHandshake { reason: reason }); + + + if let Ok(msg) = msg { + let _ = sender.send(msg).await; // we can't use send_message because we + // don't add addr to connections + } else { + warn!("Could not send reason of rejection. Server is acting like my ex..."); + return; + } } } else { warn!("Welcoming reciever closed!");