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 |
|
12857
|
9 |
pub fn handle(server: &mut HWServer, token: usize, poll: &mio::Poll, message: HWProtocolMessage) {
|
12152
|
10 |
match message {
|
|
11 |
HWProtocolMessage::Nick(nick) =>
|
|
12 |
if server.clients[token].room_id == None {
|
|
13 |
server.react(token, poll, vec![SendMe(Nick(&nick).to_raw_protocol())]);
|
|
14 |
server.clients[token].nick = nick;
|
|
15 |
server.react(token, poll, vec![CheckRegistered]);
|
|
16 |
},
|
|
17 |
HWProtocolMessage::Proto(proto) => {
|
|
18 |
server.clients[token].protocol_number = proto;
|
|
19 |
server.react(token, poll, vec![CheckRegistered]);
|
|
20 |
},
|
|
21 |
_ => warn!("Incorrect command in logging-in state"),
|
|
22 |
}
|
|
23 |
}
|