author | Wuzzy <Wuzzy2@mail.ru> |
Mon, 19 Mar 2018 15:44:39 +0100 | |
changeset 13260 | 7f8f2c77a9cc |
parent 13124 | 1e39b8749072 |
child 13421 | cdf69667593b |
permissions | -rw-r--r-- |
12152 | 1 |
use mio; |
2 |
||
3 |
use server::server::HWServer; |
|
4 |
use server::actions::Action; |
|
5 |
use server::actions::Action::*; |
|
6 |
use protocol::messages::HWProtocolMessage; |
|
7 |
use protocol::messages::HWServerMessage::*; |
|
8 |
||
13124
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12857
diff
changeset
|
9 |
pub fn handle(server: & mut HWServer, token: usize, message: HWProtocolMessage) { |
12152 | 10 |
match message { |
11 |
HWProtocolMessage::Nick(nick) => |
|
12 |
if server.clients[token].room_id == None { |
|
13124
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12857
diff
changeset
|
13 |
server.react(token, vec![SendMe(Nick(nick.clone()))]); |
12152 | 14 |
server.clients[token].nick = nick; |
13124
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12857
diff
changeset
|
15 |
server.react(token, vec![CheckRegistered]); |
12152 | 16 |
}, |
17 |
HWProtocolMessage::Proto(proto) => { |
|
18 |
server.clients[token].protocol_number = proto; |
|
13124
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12857
diff
changeset
|
19 |
server.react(token, vec![CheckRegistered]); |
12152 | 20 |
}, |
21 |
_ => warn!("Incorrect command in logging-in state"), |
|
22 |
} |
|
23 |
} |