gameServer2/src/server/client.rs
author nemo
Fri, 13 Apr 2018 13:03:51 -0400
changeset 13327 b77a9380dd0f
parent 13124 1e39b8749072
child 13424 81e0ed105f5d
permissions -rw-r--r--
QT for some reason messes with XCompose causing broken input (Qt 5 only - Qt 4 did not break anything). In Qt 5.2 and 5.3 this was causing an invalid conversion in chat messages containing these resulting in the bad bytes being stripped. In Qt 5.9 it is still broken, but you at least get a string with something in it. This checks for non-zero converted strings for room creation and chat lines.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13124
1e39b8749072 separated the server logic from all the async io mess.
alfadur
parents: 12858
diff changeset
     1
pub type ClientId = usize;
12133
f50876f3eff8 Refactor modules layout
unc0rr
parents:
diff changeset
     2
f50876f3eff8 Refactor modules layout
unc0rr
parents:
diff changeset
     3
pub struct HWClient {
13124
1e39b8749072 separated the server logic from all the async io mess.
alfadur
parents: 12858
diff changeset
     4
    pub id: ClientId,
12857
bd35cb2302b3 Quick dirty fix for building
unc0rr
parents: 12152
diff changeset
     5
    pub room_id: Option<usize>,
12146
78925eff02c2 Basic support for NICK message
unc0rr
parents: 12144
diff changeset
     6
    pub nick: String,
12151
8d8fb85bc09c SendAllButMe action, list all clients in lobby in LobbyJoined message to newcomers
unc0rr
parents: 12149
diff changeset
     7
    pub protocol_number: u32,
12152
03ccb89820f3 Room creation halfplemented
unc0rr
parents: 12151
diff changeset
     8
    pub is_master: bool,
03ccb89820f3 Room creation halfplemented
unc0rr
parents: 12151
diff changeset
     9
    pub is_ready: bool,
03ccb89820f3 Room creation halfplemented
unc0rr
parents: 12151
diff changeset
    10
    pub is_joined_mid_game: bool,
12133
f50876f3eff8 Refactor modules layout
unc0rr
parents:
diff changeset
    11
}
f50876f3eff8 Refactor modules layout
unc0rr
parents:
diff changeset
    12
f50876f3eff8 Refactor modules layout
unc0rr
parents:
diff changeset
    13
impl HWClient {
13124
1e39b8749072 separated the server logic from all the async io mess.
alfadur
parents: 12858
diff changeset
    14
    pub fn new(id: ClientId) -> HWClient {
12133
f50876f3eff8 Refactor modules layout
unc0rr
parents:
diff changeset
    15
        HWClient {
13124
1e39b8749072 separated the server logic from all the async io mess.
alfadur
parents: 12858
diff changeset
    16
            id,
12151
8d8fb85bc09c SendAllButMe action, list all clients in lobby in LobbyJoined message to newcomers
unc0rr
parents: 12149
diff changeset
    17
            room_id: None,
12146
78925eff02c2 Basic support for NICK message
unc0rr
parents: 12144
diff changeset
    18
            nick: String::new(),
12151
8d8fb85bc09c SendAllButMe action, list all clients in lobby in LobbyJoined message to newcomers
unc0rr
parents: 12149
diff changeset
    19
            protocol_number: 0,
12152
03ccb89820f3 Room creation halfplemented
unc0rr
parents: 12151
diff changeset
    20
            is_master: false,
03ccb89820f3 Room creation halfplemented
unc0rr
parents: 12151
diff changeset
    21
            is_ready: false,
03ccb89820f3 Room creation halfplemented
unc0rr
parents: 12151
diff changeset
    22
            is_joined_mid_game: false,
12133
f50876f3eff8 Refactor modules layout
unc0rr
parents:
diff changeset
    23
        }
f50876f3eff8 Refactor modules layout
unc0rr
parents:
diff changeset
    24
    }
13124
1e39b8749072 separated the server logic from all the async io mess.
alfadur
parents: 12858
diff changeset
    25
}