gameServer2/src/server/handlers/loggingin.rs
author unc0rr
Thu, 08 Mar 2018 21:58:59 +0100
changeset 13136 f10f4bf5f84d
parent 13124 1e39b8749072
child 13421 cdf69667593b
permissions -rw-r--r--
This should fix crash with custom bindings

use mio;

use server::server::HWServer;
use server::actions::Action;
use server::actions::Action::*;
use protocol::messages::HWProtocolMessage;
use protocol::messages::HWServerMessage::*;

pub fn handle(server: & mut HWServer, token: usize, message: HWProtocolMessage) {
    match message {
        HWProtocolMessage::Nick(nick) =>
            if server.clients[token].room_id == None {
                server.react(token, vec![SendMe(Nick(nick.clone()))]);
                server.clients[token].nick = nick;
                server.react(token, vec![CheckRegistered]);
            },
        HWProtocolMessage::Proto(proto) => {
            server.clients[token].protocol_number = proto;
            server.react(token, vec![CheckRegistered]);
        },
        _ => warn!("Incorrect command in logging-in state"),
    }
}