--- a/gameServer2/src/server/server.rs Sat Jan 14 22:30:09 2017 +0300
+++ b/gameServer2/src/server/server.rs Sun Jan 15 00:34:36 2017 +0300
@@ -6,6 +6,8 @@
use utils;
use server::client::HWClient;
+use server::actions::Action;
+use server::actions::Action::*;
type Slab<T> = slab::Slab<T, Token>;
@@ -44,7 +46,15 @@
pub fn client_readable(&mut self, poll: &Poll,
token: Token) -> io::Result<()> {
- self.clients[token].readable(poll)
+ let actions;
+ {
+ actions = self.clients[token].readable(poll);
+ }
+
+ for action in actions {
+ self.react(token, action);
+ }
+ Ok(())
}
pub fn client_writable(&mut self, poll: &Poll,
@@ -56,6 +66,13 @@
token: Token) -> io::Result<()> {
self.clients[token].error(poll)
}
+
+ fn react(&mut self, token: Token, action: Action) {
+ match action {
+ SendMe(msg) => self.clients[token].send_string(&msg),
+ //_ => unimplemented!(),
+ }
+ }
}