gameServer2/src/main.rs
changeset 13119 1e39b8749072
parent 12853 a9d105dc5c95
child 13414 28b314ad566d
--- a/gameServer2/src/main.rs	Thu Mar 08 16:49:49 2018 +0100
+++ b/gameServer2/src/main.rs	Thu Mar 08 15:01:18 2018 -0500
@@ -1,3 +1,5 @@
+#![allow(unused_imports)]
+
 extern crate rand;
 extern crate mio;
 extern crate slab;
@@ -7,6 +9,7 @@
 #[macro_use]
 extern crate log;
 extern crate env_logger;
+#[macro_use] extern crate proptest;
 
 //use std::io::*;
 //use rand::Rng;
@@ -18,6 +21,8 @@
 mod server;
 mod protocol;
 
+use server::network::NetworkLayer;
+
 fn main() {
     env_logger::init().unwrap();
 
@@ -25,10 +30,10 @@
 
     let address = "0.0.0.0:46631".parse().unwrap();
     let listener = TcpListener::bind(&address).unwrap();
-    let mut server = server::server::HWServer::new(listener, 1024, 512);
 
     let poll = Poll::new().unwrap();
-    server.register(&poll).unwrap();
+    let mut hw_network = NetworkLayer::new(listener, 1024, 512);
+    hw_network.register_server(&poll).unwrap();
 
     let mut events = Events::with_capacity(1024);
 
@@ -38,14 +43,14 @@
         for event in events.iter() {
             if event.readiness() & Ready::readable() == Ready::readable() {
                 match event.token() {
-                    utils::SERVER => server.accept(&poll).unwrap(),
-                    Token(tok) => server.client_readable(&poll, tok).unwrap(),
+                    utils::SERVER => hw_network.accept_client(&poll).unwrap(),
+                    Token(tok) => hw_network.client_readable(&poll, tok).unwrap(),
                 }
             }
             if event.readiness() & Ready::writable() == Ready::writable() {
                 match event.token() {
                     utils::SERVER => unreachable!(),
-                    Token(tok) => server.client_writable(&poll, tok).unwrap(),
+                    Token(tok) => hw_network.client_writable(&poll, tok).unwrap(),
                 }
             }
 //            if event.kind().is_hup() || event.kind().is_error() {