rust/hedgewars-server/src/server/handlers/common.rs
changeset 14694 08a8605bafaf
parent 14478 98ef2913ec73
child 14695 b87c71ccd17d
--- a/rust/hedgewars-server/src/server/handlers/common.rs	Mon Feb 04 19:22:21 2019 +0300
+++ b/rust/hedgewars-server/src/server/handlers/common.rs	Mon Feb 04 20:25:35 2019 +0300
@@ -21,6 +21,15 @@
     }
 }
 
+pub fn remove_client(server: &mut HWServer, response: &mut super::Response, msg: String) {
+    use HWServerMessage::*;
+    let nick = server.clients[response.client_id()].nick.clone();
+    response.add(LobbyLeft(nick, msg.to_string()).send_all());
+    response.add(Bye("User quit: ".to_string() + &msg).send_self());
+
+    server.remove_client(response.client_id());
+}
+
 #[cfg(test)]
 mod tests {
     use super::*;