gameServer2/src/server/handlers/loggingin.rs
author Wuzzy <Wuzzy2@mail.ru>
Tue, 17 Apr 2018 00:37:15 +0200
changeset 13327 817e1890ee66
parent 13119 1e39b8749072
child 13416 cdf69667593b
permissions -rw-r--r--
Added tag 0.9.24-release for changeset a4e7e62f2c0d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12147
03ccb89820f3 Room creation halfplemented
unc0rr
parents:
diff changeset
     1
use mio;
03ccb89820f3 Room creation halfplemented
unc0rr
parents:
diff changeset
     2
03ccb89820f3 Room creation halfplemented
unc0rr
parents:
diff changeset
     3
use server::server::HWServer;
03ccb89820f3 Room creation halfplemented
unc0rr
parents:
diff changeset
     4
use server::actions::Action;
03ccb89820f3 Room creation halfplemented
unc0rr
parents:
diff changeset
     5
use server::actions::Action::*;
03ccb89820f3 Room creation halfplemented
unc0rr
parents:
diff changeset
     6
use protocol::messages::HWProtocolMessage;
03ccb89820f3 Room creation halfplemented
unc0rr
parents:
diff changeset
     7
use protocol::messages::HWServerMessage::*;
03ccb89820f3 Room creation halfplemented
unc0rr
parents:
diff changeset
     8
13119
1e39b8749072 separated the server logic from all the async io mess.
alfadur
parents: 12852
diff changeset
     9
pub fn handle(server: & mut HWServer, token: usize, message: HWProtocolMessage) {
12147
03ccb89820f3 Room creation halfplemented
unc0rr
parents:
diff changeset
    10
    match message {
03ccb89820f3 Room creation halfplemented
unc0rr
parents:
diff changeset
    11
        HWProtocolMessage::Nick(nick) =>
03ccb89820f3 Room creation halfplemented
unc0rr
parents:
diff changeset
    12
            if server.clients[token].room_id == None {
13119
1e39b8749072 separated the server logic from all the async io mess.
alfadur
parents: 12852
diff changeset
    13
                server.react(token, vec![SendMe(Nick(nick.clone()))]);
12147
03ccb89820f3 Room creation halfplemented
unc0rr
parents:
diff changeset
    14
                server.clients[token].nick = nick;
13119
1e39b8749072 separated the server logic from all the async io mess.
alfadur
parents: 12852
diff changeset
    15
                server.react(token, vec![CheckRegistered]);
12147
03ccb89820f3 Room creation halfplemented
unc0rr
parents:
diff changeset
    16
            },
03ccb89820f3 Room creation halfplemented
unc0rr
parents:
diff changeset
    17
        HWProtocolMessage::Proto(proto) => {
03ccb89820f3 Room creation halfplemented
unc0rr
parents:
diff changeset
    18
            server.clients[token].protocol_number = proto;
13119
1e39b8749072 separated the server logic from all the async io mess.
alfadur
parents: 12852
diff changeset
    19
            server.react(token, vec![CheckRegistered]);
12147
03ccb89820f3 Room creation halfplemented
unc0rr
parents:
diff changeset
    20
        },
03ccb89820f3 Room creation halfplemented
unc0rr
parents:
diff changeset
    21
        _ => warn!("Incorrect command in logging-in state"),
03ccb89820f3 Room creation halfplemented
unc0rr
parents:
diff changeset
    22
    }
03ccb89820f3 Room creation halfplemented
unc0rr
parents:
diff changeset
    23
}