equal
deleted
inserted
replaced
17 |
17 |
18 pub id: Token, |
18 pub id: Token, |
19 pub room_id: Option<Token>, |
19 pub room_id: Option<Token>, |
20 pub nick: String, |
20 pub nick: String, |
21 pub protocol_number: u32, |
21 pub protocol_number: u32, |
|
22 pub is_master: bool, |
|
23 pub is_ready: bool, |
|
24 pub is_joined_mid_game: bool, |
22 } |
25 } |
23 |
26 |
24 impl HWClient { |
27 impl HWClient { |
25 pub fn new(sock: TcpStream) -> HWClient { |
28 pub fn new(sock: TcpStream) -> HWClient { |
26 HWClient { |
29 HWClient { |
30 room_id: None, |
33 room_id: None, |
31 id: Token(0), |
34 id: Token(0), |
32 |
35 |
33 nick: String::new(), |
36 nick: String::new(), |
34 protocol_number: 0, |
37 protocol_number: 0, |
|
38 is_master: false, |
|
39 is_ready: false, |
|
40 is_joined_mid_game: false, |
35 } |
41 } |
36 } |
42 } |
37 |
43 |
38 pub fn register(&mut self, poll: &Poll, token: Token) { |
44 pub fn register(&mut self, poll: &Poll, token: Token) { |
39 poll.register(&self.sock, token, Ready::all(), |
45 poll.register(&self.sock, token, Ready::all(), |
42 |
48 |
43 self.send_msg(HWServerMessage::Connected(utils::PROTOCOL_VERSION)); |
49 self.send_msg(HWServerMessage::Connected(utils::PROTOCOL_VERSION)); |
44 } |
50 } |
45 |
51 |
46 pub fn deregister(&mut self, poll: &Poll) { |
52 pub fn deregister(&mut self, poll: &Poll) { |
47 poll.deregister(&self.sock); |
53 poll.deregister(&self.sock) |
|
54 .ok().expect("could not deregister socket"); |
48 } |
55 } |
49 |
56 |
50 pub fn send_raw_msg(&mut self, msg: &[u8]) { |
57 pub fn send_raw_msg(&mut self, msg: &[u8]) { |
51 self.buf_out.write(msg).unwrap(); |
58 self.buf_out.write(msg).unwrap(); |
52 self.flush(); |
59 self.flush(); |