fix: not sending rejection message

This commit is contained in:
2026-08-16 18:32:36 +02:00
parent 44051b0ed8
commit 429ab21670

View File

@@ -137,8 +137,19 @@ impl Server {
self.connections.insert(addr, sender); self.connections.insert(addr, sender);
self.request_handshake(addr).await; self.request_handshake(addr).await;
} else { } else {
let msg = Message::new(ServerMessage::DeclineHandshake { reason: "There is currently game going and it doesn't allow spectators".to_string() }); let reason = "There is currently game going and it doesn't allow spectators".to_string();
self.send_message(addr, msg).await; 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 { } else {
warn!("Welcoming reciever closed!"); warn!("Welcoming reciever closed!");