--- a/gameServer2/src/server/server.rs Fri Jul 06 21:03:03 2018 +0300
+++ b/gameServer2/src/server/server.rs Sat Jul 07 20:22:31 2018 +0300
@@ -1,7 +1,8 @@
use slab;
use utils;
use super::{
- client::*, room::*, actions, handlers,
+ client::HWClient, room::HWRoom, actions, handlers,
+ coretypes::{ClientId, RoomId},
actions::{Destination, PendingMessage}
};
use protocol::messages::*;
@@ -105,6 +106,14 @@
self.rooms.iter_mut().find(|(_, r)| r.name == name).map(|(_, r)| r)
}
+ pub fn find_client(&self, nick: &str) -> Option<&HWClient> {
+ self.clients.iter().find(|(_, c)| c.nick == nick).map(|(_, c)| c)
+ }
+
+ pub fn find_client_mut(&mut self, nick: &str) -> Option<&mut HWClient> {
+ self.clients.iter_mut().find(|(_, c)| c.nick == nick).map(|(_, c)| c)
+ }
+
pub fn select_clients<F>(&self, f: F) -> Vec<ClientId>
where F: Fn(&(usize, &HWClient)) -> bool {
self.clients.iter().filter(f)