rust/hedgewars-server/src/server/handlers.rs
changeset 14457 98ef2913ec73
parent 14415 06672690d71b
child 14671 455865ccd36c
--- a/rust/hedgewars-server/src/server/handlers.rs	Sun Dec 16 00:09:20 2018 +0100
+++ b/rust/hedgewars-server/src/server/handlers.rs	Sun Dec 16 00:12:29 2018 +0100
@@ -2,43 +2,34 @@
 use std::{io, io::Write};
 
 use super::{
+    actions::{Action, Action::*},
     core::HWServer,
-    actions::{Action, Action::*},
-    coretypes::ClientId
+    coretypes::ClientId,
 };
-use crate::{
-    protocol::messages::{
-        HWProtocolMessage,
-        HWServerMessage::*
-    }
-};
+use crate::protocol::messages::{HWProtocolMessage, HWServerMessage::*};
 use log::*;
 
-mod loggingin;
-mod lobby;
+mod checker;
+mod common;
 mod inroom;
-mod common;
-mod checker;
+mod lobby;
+mod loggingin;
 
 pub fn handle(server: &mut HWServer, client_id: ClientId, message: HWProtocolMessage) {
     match message {
-        HWProtocolMessage::Ping =>
-            server.react(client_id, vec![Pong.send_self().action()]),
-        HWProtocolMessage::Quit(Some(msg)) =>
-            server.react(client_id, vec![ByeClient("User quit: ".to_string() + &msg)]),
-        HWProtocolMessage::Quit(None) =>
-            server.react(client_id, vec![ByeClient("User quit".to_string())]),
+        HWProtocolMessage::Ping => server.react(client_id, vec![Pong.send_self().action()]),
+        HWProtocolMessage::Quit(Some(msg)) => {
+            server.react(client_id, vec![ByeClient("User quit: ".to_string() + &msg)])
+        }
+        HWProtocolMessage::Quit(None) => {
+            server.react(client_id, vec![ByeClient("User quit".to_string())])
+        }
         HWProtocolMessage::Malformed => warn!("Malformed/unknown message"),
         HWProtocolMessage::Empty => warn!("Empty message"),
-        _ => {
-            match server.clients[client_id].room_id {
-                None =>
-                    loggingin::handle(server, client_id, message),
-                Some(id) if id == server.lobby_id =>
-                    lobby::handle(server, client_id, message),
-                Some(id) =>
-                    inroom::handle(server, client_id, id, message)
-            }
+        _ => match server.clients[client_id].room_id {
+            None => loggingin::handle(server, client_id, message),
+            Some(id) if id == server.lobby_id => lobby::handle(server, client_id, message),
+            Some(id) => inroom::handle(server, client_id, id, message),
         },
     }
 }