equal
deleted
inserted
replaced
8 use protocol::messages::{ |
8 use protocol::messages::{ |
9 HWProtocolMessage, |
9 HWProtocolMessage, |
10 HWServerMessage::* |
10 HWServerMessage::* |
11 }; |
11 }; |
12 use utils::is_name_illegal; |
12 use utils::is_name_illegal; |
|
13 use super::common::rnd_reply; |
13 |
14 |
14 pub fn handle(server: &mut HWServer, client_id: ClientId, message: HWProtocolMessage) { |
15 pub fn handle(server: &mut HWServer, client_id: ClientId, message: HWProtocolMessage) { |
15 use protocol::messages::HWProtocolMessage::*; |
16 use protocol::messages::HWProtocolMessage::*; |
16 match message { |
17 match message { |
17 CreateRoom(name, password) => { |
18 CreateRoom(name, password) => { |
28 flags_msg.send_self().action()] |
29 flags_msg.send_self().action()] |
29 }; |
30 }; |
30 server.react(client_id, actions); |
31 server.react(client_id, actions); |
31 }, |
32 }, |
32 Chat(msg) => { |
33 Chat(msg) => { |
33 let chat_msg = ChatMsg(server.clients[client_id].nick.clone(), msg); |
34 let chat_msg = ChatMsg {nick: server.clients[client_id].nick.clone(), msg: msg}; |
34 server.react(client_id, vec![chat_msg.send_all().but_self().action()]); |
35 server.react(client_id, vec![chat_msg.send_all().but_self().action()]); |
35 }, |
36 }, |
36 JoinRoom(name, password) => { |
37 JoinRoom(name, password) => { |
37 let actions; |
38 let actions; |
38 { |
39 { |
55 vec![Warn("No such room.".to_string())] |
56 vec![Warn("No such room.".to_string())] |
56 }; |
57 }; |
57 } |
58 } |
58 server.react(client_id, actions); |
59 server.react(client_id, actions); |
59 }, |
60 }, |
|
61 Rnd(v) => server.react(client_id, rnd_reply(v)), |
60 List => warn!("Deprecated LIST message received"), |
62 List => warn!("Deprecated LIST message received"), |
61 _ => warn!("Incorrect command in lobby state"), |
63 _ => warn!("Incorrect command in lobby state"), |
62 } |
64 } |
63 } |
65 } |