equal
deleted
inserted
replaced
2 use mio::tcp::*; |
2 use mio::tcp::*; |
3 use mio::*; |
3 use mio::*; |
4 use std::io; |
4 use std::io; |
5 |
5 |
6 use utils; |
6 use utils; |
7 use server::client::HWClient; |
7 use super::client::HWClient; |
8 use server::actions::Action; |
8 use super::actions; |
9 use super::handlers; |
|
10 |
9 |
11 type Slab<T> = slab::Slab<T, Token>; |
10 type Slab<T> = slab::Slab<T, Token>; |
12 |
11 |
13 pub struct HWServer { |
12 pub struct HWServer { |
14 listener: TcpListener, |
13 listener: TcpListener, |
80 |
79 |
81 pub fn send(&mut self, token: Token, msg: &String) { |
80 pub fn send(&mut self, token: Token, msg: &String) { |
82 self.clients[token].send_string(msg); |
81 self.clients[token].send_string(msg); |
83 } |
82 } |
84 |
83 |
85 pub fn react(&mut self, token: Token, poll: &Poll, actions: Vec<Action>) { |
84 pub fn react(&mut self, token: Token, poll: &Poll, actions: Vec<actions::Action>) { |
86 for action in actions { |
85 for action in actions { |
87 handlers::handle(self, token, poll, action); |
86 actions::run_action(self, token, poll, action); |
88 } |
87 } |
89 } |
88 } |
90 } |
89 } |
91 |
90 |
92 |
91 |