--- a/gameServer2/src/main.rs Wed Dec 06 23:46:17 2017 +0100
+++ b/gameServer2/src/main.rs Sat Dec 16 22:58:28 2017 +0100
@@ -11,7 +11,7 @@
//use std::io::*;
//use rand::Rng;
//use std::cmp::Ordering;
-use mio::tcp::*;
+use mio::net::*;
use mio::*;
mod utils;
@@ -36,24 +36,24 @@
poll.poll(&mut events, None).unwrap();
for event in events.iter() {
- if event.kind().is_readable() {
+ if event.readiness() & Ready::readable() == Ready::readable() {
match event.token() {
utils::SERVER => server.accept(&poll).unwrap(),
Token(tok) => server.client_readable(&poll, tok).unwrap(),
}
}
- if event.kind().is_writable() {
+ if event.readiness() & Ready::writable() == Ready::writable() {
match event.token() {
utils::SERVER => unreachable!(),
Token(tok) => server.client_writable(&poll, tok).unwrap(),
}
}
- if event.kind().is_hup() || event.kind().is_error() {
- match event.token() {
- utils::SERVER => unreachable!(),
- Token(tok) => server.client_error(&poll, tok).unwrap(),
- }
- }
+// if event.kind().is_hup() || event.kind().is_error() {
+// match event.token() {
+// utils::SERVER => unreachable!(),
+// Token(tok) => server.client_error(&poll, tok).unwrap(),
+// }
+// }
}
}
}
--- a/gameServer2/src/server/actions.rs Wed Dec 06 23:46:17 2017 +0100
+++ b/gameServer2/src/server/actions.rs Sat Dec 16 22:58:28 2017 +0100
@@ -27,7 +27,7 @@
SendMe(msg) =>
server.send(token, &msg),
SendAllButMe(msg) => {
- for (i, c) in server.clients.iter_mut() {
+ for (_i, c) in server.clients.iter_mut() {
if c.id != token {
c.send_string(&msg)
}
--- a/gameServer2/src/server/client.rs Wed Dec 06 23:46:17 2017 +0100
+++ b/gameServer2/src/server/client.rs Sat Dec 16 22:58:28 2017 +0100
@@ -42,7 +42,7 @@
}
pub fn register(&mut self, poll: &Poll, token: Token) {
- poll.register(&self.sock, token, Ready::all(),
+ poll.register(&self.sock, token, Ready::readable() | Ready::writable(),
PollOpt::edge())
.ok().expect("could not register socket with event loop");
@@ -72,7 +72,7 @@
self.sock.flush();
}
- pub fn readable(&mut self, poll: &Poll) -> Vec<Action> {
+ pub fn readable(&mut self, _poll: &Poll) -> Vec<Action> {
let v = self.decoder.read_from(&mut self.sock).unwrap();
debug!("Read {} bytes", v);
let mut response = Vec::new();
@@ -85,13 +85,13 @@
response
}
- pub fn writable(&mut self, poll: &Poll) -> io::Result<()> {
+ pub fn writable(&mut self, _poll: &Poll) -> io::Result<()> {
self.buf_out.write_to(&mut self.sock)?;
Ok(())
}
- pub fn error(&mut self, poll: &Poll) -> Vec<Action> {
+ pub fn error(&mut self, _poll: &Poll) -> Vec<Action> {
return vec![ByeClient("Connection reset".to_string())]
}
}
--- a/gameServer2/src/server/handlers/inroom.rs Wed Dec 06 23:46:17 2017 +0100
+++ b/gameServer2/src/server/handlers/inroom.rs Sat Dec 16 22:58:28 2017 +0100
@@ -6,7 +6,7 @@
use protocol::messages::HWProtocolMessage;
use protocol::messages::HWServerMessage::*;
-pub fn handle(server: &mut HWServer, token: usize, poll: &mio::Poll, message: HWProtocolMessage) {
+pub fn handle(server: &mut HWServer, token: usize, _poll: &mio::Poll, message: HWProtocolMessage) {
match message {
_ => warn!("Unimplemented!"),
}