gameServer2/src/server/handlers/loggingin.rs
changeset 12152 03ccb89820f3
child 12857 bd35cb2302b3
equal deleted inserted replaced
12151:8d8fb85bc09c 12152:03ccb89820f3
       
     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: mio::Token, poll: &mio::Poll, message: HWProtocolMessage) {
       
    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 }