gameServer2/src/server/handlers/loggingin.rs
branchui-scaling
changeset 15283 c4fd2813b127
parent 13390 0135e64c6c66
parent 15279 7ab5cf405686
child 15663 d92eeb468dad
equal deleted inserted replaced
13390:0135e64c6c66 15283:c4fd2813b127
     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 
       
     9 pub fn handle(server: & mut HWServer, token: usize, message: HWProtocolMessage) {
       
    10     match message {
       
    11         HWProtocolMessage::Nick(nick) =>
       
    12             if server.clients[token].room_id == None {
       
    13                 server.react(token, vec![SendMe(Nick(nick.clone()))]);
       
    14                 server.clients[token].nick = nick;
       
    15                 server.react(token, vec![CheckRegistered]);
       
    16             },
       
    17         HWProtocolMessage::Proto(proto) => {
       
    18             server.clients[token].protocol_number = proto;
       
    19             server.react(token, vec![CheckRegistered]);
       
    20         },
       
    21         _ => warn!("Incorrect command in logging-in state"),
       
    22     }
       
    23 }