@@ -32,6 +32,7 @@ pub trait Game {
32
32
/// returns bool value indicating
33
33
/// should server continue running if false stops server
34
34
/// called only when new commands come to server
35
+ /// Commands ordered and with some guarantees.
35
36
fn handle_command (
36
37
& mut self ,
37
38
delta_time : Duration ,
@@ -43,6 +44,7 @@ pub trait Game {
43
44
/// returns bytes with new game state for client
44
45
/// called once in about 30 milliseconds
45
46
/// sends state only to clients connected to server
47
+ ///ordered and without some guarantees.
46
48
fn draw ( & mut self , delta_time : Duration ) -> Vec < u8 > ;
47
49
///allow client with this IP Address work with server
48
50
/// if false server don't send new state to this client
@@ -65,6 +67,7 @@ pub trait Game {
65
67
None
66
68
}
67
69
///Disconnect this client from server and don't send new state to them
70
+ /// usually don't implement this method. Use default implementation
68
71
fn remove_client ( & mut self ) -> Option < SocketAddr > {
69
72
None
70
73
}
@@ -88,14 +91,16 @@ impl ClientSocket {
88
91
///Send data to server
89
92
/// Don't block current thread
90
93
/// may wait up to 30 milliseconds if you send commands too often
94
+ ///Commands ordered and with some guarantees.
91
95
pub fn send ( & mut self , command : Vec < u8 > ) -> Result < usize , Exception > {
92
96
let command = self . client . send ( command) ;
93
97
self . socket . write ( & command)
94
98
}
95
99
96
100
///Reads data fro server
97
101
/// Don't block current thread
98
- /// Return None if there is no data available
102
+ /// Return [`Exception`] with [`io::ErrorKind::WouldBlock`] if there is no data available.
103
+ ///Data ordered and without some guarantees.
99
104
pub fn recv ( & mut self ) -> Result < Vec < u8 > , Exception > {
100
105
let state = self . socket . read ( ) ?;
101
106
let ( state, lost) = self . client . recv ( state) ?;
0 commit comments