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_action; |
13 use super::common::rnd_reply; |
14 |
14 |
15 pub fn handle(server: &mut HWServer, client_id: ClientId, message: HWProtocolMessage) { |
15 pub fn handle(server: &mut HWServer, client_id: ClientId, message: HWProtocolMessage) { |
16 use protocol::messages::HWProtocolMessage::*; |
16 use protocol::messages::HWProtocolMessage::*; |
17 match message { |
17 match message { |
18 CreateRoom(name, password) => { |
18 CreateRoom(name, password) => { |
29 flags_msg.send_self().action()] |
29 flags_msg.send_self().action()] |
30 }; |
30 }; |
31 server.react(client_id, actions); |
31 server.react(client_id, actions); |
32 }, |
32 }, |
33 Chat(msg) => { |
33 Chat(msg) => { |
34 let chat_msg = ChatMsg {nick: server.clients[client_id].nick.clone(), msg: msg}; |
34 let actions = vec![ChatMsg {nick: server.clients[client_id].nick.clone(), msg} |
35 server.react(client_id, vec![chat_msg.send_all().but_self().action()]); |
35 .send_all().in_room(server.lobby_id).but_self().action()]; |
|
36 server.react(client_id, actions); |
36 }, |
37 }, |
37 JoinRoom(name, password) => { |
38 JoinRoom(name, password) => { |
38 let actions; |
39 let actions; |
39 { |
40 { |
40 let room = server.rooms.iter().find(|(_, r)| r.name == name); |
41 let room = server.rooms.iter().find(|(_, r)| r.name == name); |
57 }; |
58 }; |
58 } |
59 } |
59 server.react(client_id, actions); |
60 server.react(client_id, actions); |
60 }, |
61 }, |
61 Rnd(v) => { |
62 Rnd(v) => { |
62 let actions = rnd_action(v, server.room(client_id)); |
63 server.react(client_id, vec![rnd_reply(&v).send_self().action()]); |
63 server.react(client_id, actions) |
|
64 }, |
64 }, |
65 List => warn!("Deprecated LIST message received"), |
65 List => warn!("Deprecated LIST message received"), |
66 _ => warn!("Incorrect command in lobby state"), |
66 _ => warn!("Incorrect command in lobby state"), |
67 } |
67 } |
68 } |
68 } |