equal
deleted
inserted
replaced
38 let entry = self.clients.vacant_entry(); |
38 let entry = self.clients.vacant_entry(); |
39 key = entry.key(); |
39 key = entry.key(); |
40 let client = HWClient::new(entry.key()); |
40 let client = HWClient::new(entry.key()); |
41 entry.insert(client); |
41 entry.insert(client); |
42 } |
42 } |
43 self.send(key, Destination::ToSelf, HWServerMessage::Connected(utils::PROTOCOL_VERSION)); |
43 self.send(key, &Destination::ToSelf, HWServerMessage::Connected(utils::PROTOCOL_VERSION)); |
44 key |
44 key |
45 } |
45 } |
46 |
46 |
47 pub fn client_lost(&mut self, client_id: ClientId) { |
47 pub fn client_lost(&mut self, client_id: ClientId) { |
48 actions::run_action(self, client_id, |
48 actions::run_action(self, client_id, |
62 if self.clients.contains(client_id) { |
62 if self.clients.contains(client_id) { |
63 handlers::handle(self, client_id, msg); |
63 handlers::handle(self, client_id, msg); |
64 } |
64 } |
65 } |
65 } |
66 |
66 |
67 fn get_recipients(&self, client_id: ClientId, destination: Destination) -> Vec<ClientId> { |
67 fn get_recipients(&self, client_id: ClientId, destination: &Destination) -> Vec<ClientId> { |
68 let mut ids = match destination { |
68 let mut ids = match *destination { |
69 Destination::ToSelf => vec![client_id], |
69 Destination::ToSelf => vec![client_id], |
70 Destination::ToId(id) => vec![id], |
70 Destination::ToId(id) => vec![id], |
71 Destination::ToAll {room_id: Some(id), ..} => |
71 Destination::ToAll {room_id: Some(id), ..} => |
72 self.room_clients(id), |
72 self.room_clients(id), |
73 Destination::ToAll {protocol: Some(proto), ..} => |
73 Destination::ToAll {protocol: Some(proto), ..} => |
81 } |
81 } |
82 } |
82 } |
83 ids |
83 ids |
84 } |
84 } |
85 |
85 |
86 pub fn send(&mut self, client_id: ClientId, destination: Destination, message: HWServerMessage) { |
86 pub fn send(&mut self, client_id: ClientId, destination: &Destination, message: HWServerMessage) { |
87 let ids = self.get_recipients(client_id, destination); |
87 let ids = self.get_recipients(client_id, &destination); |
88 self.output.push((ids, message)); |
88 self.output.push((ids, message)); |
89 } |
89 } |
90 |
90 |
91 pub fn react(&mut self, client_id: ClientId, actions: Vec<actions::Action>) { |
91 pub fn react(&mut self, client_id: ClientId, actions: Vec<actions::Action>) { |
92 for action in actions { |
92 for action in actions { |