gameServer2/src/server/client.rs
changeset 12144 589a2d7d3dc5
parent 12143 7e874846afe3
child 12146 8d8fb85bc09c
equal deleted inserted replaced
12143:7e874846afe3 12144:589a2d7d3dc5
     5 use netbuf;
     5 use netbuf;
     6 
     6 
     7 use utils;
     7 use utils;
     8 use protocol::ProtocolDecoder;
     8 use protocol::ProtocolDecoder;
     9 use protocol::messages::*;
     9 use protocol::messages::*;
    10 use server::actions::Action::*;
    10 use super::actions::Action::*;
    11 use server::actions::Action;
    11 use super::actions::Action;
    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     pub nick: String,
    19     pub nick: String,
    18     room_id: Token,
    20     pub protocolNumber: u32,
    19 }
    21 }
    20 
    22 
    21 impl HWClient {
    23 impl HWClient {
    22     pub fn new(sock: TcpStream, roomId: &Token) -> HWClient {
    24     pub fn new(sock: TcpStream, roomId: &Token) -> HWClient {
    23         HWClient {
    25         HWClient {
    24             sock: sock,
    26             sock: sock,
    25             decoder: ProtocolDecoder::new(),
    27             decoder: ProtocolDecoder::new(),
    26             buf_out: netbuf::Buf::new(),
    28             buf_out: netbuf::Buf::new(),
       
    29             room_id: roomId.clone(),
       
    30 
    27             nick: String::new(),
    31             nick: String::new(),
    28             room_id: roomId.clone(),
    32             protocolNumber: 0,
    29         }
    33         }
    30     }
    34     }
    31 
    35 
    32     pub fn register(&mut self, poll: &Poll, token: Token) {
    36     pub fn register(&mut self, poll: &Poll, token: Token) {
    33         poll.register(&self.sock, token, Ready::all(),
    37         poll.register(&self.sock, token, Ready::all(),