gameServer2/src/server/client.rs
changeset 12146 8d8fb85bc09c
parent 12144 589a2d7d3dc5
child 12147 03ccb89820f3
equal deleted inserted replaced
12145:a482c7a5f6e3 12146:8d8fb85bc09c
    12 
    12 
    13 pub struct HWClient {
    13 pub struct HWClient {
    14     sock: TcpStream,
    14     sock: TcpStream,
    15     decoder: ProtocolDecoder,
    15     decoder: ProtocolDecoder,
    16     buf_out: netbuf::Buf,
    16     buf_out: netbuf::Buf,
    17     room_id: Token,
       
    18 
    17 
       
    18     pub id: Token,
       
    19     pub room_id: Option<Token>,
    19     pub nick: String,
    20     pub nick: String,
    20     pub protocolNumber: u32,
    21     pub protocol_number: u32,
    21 }
    22 }
    22 
    23 
    23 impl HWClient {
    24 impl HWClient {
    24     pub fn new(sock: TcpStream, roomId: &Token) -> HWClient {
    25     pub fn new(sock: TcpStream) -> HWClient {
    25         HWClient {
    26         HWClient {
    26             sock: sock,
    27             sock: sock,
    27             decoder: ProtocolDecoder::new(),
    28             decoder: ProtocolDecoder::new(),
    28             buf_out: netbuf::Buf::new(),
    29             buf_out: netbuf::Buf::new(),
    29             room_id: roomId.clone(),
    30             room_id: None,
       
    31             id: Token(0),
    30 
    32 
    31             nick: String::new(),
    33             nick: String::new(),
    32             protocolNumber: 0,
    34             protocol_number: 0,
    33         }
    35         }
    34     }
    36     }
    35 
    37 
    36     pub fn register(&mut self, poll: &Poll, token: Token) {
    38     pub fn register(&mut self, poll: &Poll, token: Token) {
    37         poll.register(&self.sock, token, Ready::all(),
    39         poll.register(&self.sock, token, Ready::all(),