--- a/gameServer2/src/server/handlers/lobby.rs Thu Mar 08 16:49:49 2018 +0100
+++ b/gameServer2/src/server/handlers/lobby.rs Thu Mar 08 15:01:18 2018 -0500
@@ -6,34 +6,35 @@
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, message: HWProtocolMessage) {
+ use protocol::messages::HWProtocolMessage::*;
match message {
- HWProtocolMessage::Chat(msg) => {
- let chat_msg = ChatMsg(&server.clients[token].nick, &msg).to_raw_protocol();
- server.react(token, poll, vec![SendAllButMe(chat_msg)]);
+ Chat(msg) => {
+ let chat_msg = ChatMsg(server.clients[token].nick.clone(), msg);
+ server.react(token, vec![SendAllButMe(chat_msg)]);
},
- HWProtocolMessage::CreateRoom(name, password) => {
+ CreateRoom(name, password) => {
let room_exists = server.rooms.iter().find(|&(_, r)| r.name == name).is_some();
if room_exists {
- server.react(token, poll, vec![Warn("Room exists".to_string())]);
+ server.react(token, vec![Warn("Room exists".to_string())]);
} else {
- let flags_msg = ClientFlags("+hr", &[&server.clients[token].nick]).to_raw_protocol();
+ let flags_msg = ClientFlags("+hr".to_string(), vec![server.clients[token].nick.clone()]);
{
let c = &mut server.clients[token];
c.is_master = true;
c.is_ready = true;
c.is_joined_mid_game = false;
}
- server.react(token, poll, vec![
+ server.react(token, vec![
AddRoom(name, password)
, SendMe(flags_msg)
]);
}
},
- HWProtocolMessage::Join(name, password) => {
+ Join(name, password) => {
},
- HWProtocolMessage::List => warn!("Deprecated LIST message received"),
+ List => warn!("Deprecated LIST message received"),
_ => warn!("Incorrect command in lobby state"),
}
}