author | alfadur |
Tue, 26 Jun 2018 23:22:38 +0300 | |
changeset 13422 | 5fb27f94fc3b |
parent 13419 | 81e0ed105f5d |
child 13423 | 87a6cad20c90 |
permissions | -rw-r--r-- |
12130 | 1 |
use server::coretypes::{ServerVar, GameCfg, TeamInfo, HedgehogInfo}; |
12131 | 2 |
use std; |
3 |
use std::ops; |
|
4 |
use std::convert::From; |
|
12130 | 5 |
|
13119
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
6 |
#[derive(PartialEq, Eq, Clone, Debug)] |
12142
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
7 |
pub enum HWProtocolMessage { |
12130 | 8 |
// core |
9 |
Ping, |
|
10 |
Pong, |
|
12142
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
11 |
Quit(Option<String>), |
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
12 |
//Cmd(String, Vec<String>), |
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
13 |
Global(String), |
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
14 |
Watch(String), |
12130 | 15 |
ToggleServerRegisteredOnly, |
16 |
SuperPower, |
|
12142
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
17 |
Info(String), |
12130 | 18 |
// not entered state |
12142
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
19 |
Nick(String), |
12130 | 20 |
Proto(u32), |
12142
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
21 |
Password(String, String), |
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
22 |
Checker(u32, String, String), |
12130 | 23 |
// lobby |
24 |
List, |
|
12142
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
25 |
Chat(String), |
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
26 |
CreateRoom(String, Option<String>), |
13416 | 27 |
JoinRoom(String, Option<String>), |
12142
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
28 |
Follow(String), |
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
29 |
Rnd(Vec<String>), |
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
30 |
Kick(String), |
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
31 |
Ban(String, String, u32), |
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
32 |
BanIP(String, String, u32), |
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
33 |
BanNick(String, String, u32), |
12130 | 34 |
BanList, |
12142
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
35 |
Unban(String), |
12130 | 36 |
SetServerVar(ServerVar), |
37 |
GetServerVar, |
|
38 |
RestartServer, |
|
39 |
Stats, |
|
40 |
// in room |
|
12142
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
41 |
Part(Option<String>), |
12130 | 42 |
Cfg(GameCfg), |
43 |
AddTeam(TeamInfo), |
|
12142
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
44 |
RemoveTeam(String), |
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
45 |
SetHedgehogsNumber(String, u8), |
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
46 |
SetTeamColor(String, u8), |
12130 | 47 |
ToggleReady, |
48 |
StartGame, |
|
12142
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
49 |
EngineMessage(String), |
12130 | 50 |
RoundFinished, |
51 |
ToggleRestrictJoin, |
|
52 |
ToggleRestrictTeams, |
|
53 |
ToggleRegisteredOnly, |
|
12142
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
54 |
RoomName(String), |
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
55 |
Delegate(String), |
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
56 |
TeamChat(String), |
12130 | 57 |
MaxTeams(u8), |
58 |
Fix, |
|
59 |
Unfix, |
|
12142
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
60 |
Greeting(String), |
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
61 |
CallVote(Option<(String, Option<String>)>), |
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
62 |
Vote(String), |
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
63 |
ForceVote(String), |
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
64 |
Save(String, String), |
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
65 |
Delete(String), |
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
66 |
SaveRoom(String), |
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
67 |
LoadRoom(String), |
12137
193dfdcb0620
- Use logging facilities instead of plain println!
unc0rr
parents:
12136
diff
changeset
|
68 |
Malformed, |
193dfdcb0620
- Use logging facilities instead of plain println!
unc0rr
parents:
12136
diff
changeset
|
69 |
Empty, |
12130 | 70 |
} |
12131 | 71 |
|
13416 | 72 |
#[derive(Debug)] |
13119
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
73 |
pub enum HWServerMessage { |
12142
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
74 |
Ping, |
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
75 |
Pong, |
13119
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
76 |
Bye(String), |
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
77 |
Nick(String), |
13416 | 78 |
Proto(u32), |
79 |
LobbyLeft(String, String), |
|
13119
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
80 |
LobbyJoined(Vec<String>), |
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
81 |
ChatMsg(String, String), |
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
82 |
ClientFlags(String, Vec<String>), |
13416 | 83 |
Rooms(Vec<String>), |
84 |
RoomAdd(Vec<String>), |
|
85 |
RoomJoined(Vec<String>), |
|
86 |
RoomLeft(String, String), |
|
87 |
RoomRemove(String), |
|
88 |
RoomUpdated(String, Vec<String>), |
|
13419 | 89 |
TeamAdd(Vec<String>), |
90 |
TeamRemove(String), |
|
91 |
TeamAccepted(String), |
|
92 |
TeamColor(String, u8), |
|
93 |
HedgehogsNumber(String, u8), |
|
13422 | 94 |
ConfigEntry(String, Vec<String>), |
13419 | 95 |
|
13416 | 96 |
ServerMessage(String), |
13119
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
97 |
Warning(String), |
13416 | 98 |
Error(String), |
12142
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
99 |
Connected(u32), |
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
100 |
Unreachable, |
12131 | 101 |
} |
12136 | 102 |
|
13422 | 103 |
impl GameCfg { |
104 |
pub fn into_server_msg(self) -> HWServerMessage { |
|
105 |
use self::HWServerMessage::ConfigEntry; |
|
106 |
use server::coretypes::GameCfg::*; |
|
107 |
match self { |
|
108 |
FeatureSize(s) => ConfigEntry("FEATURE_SIZE".to_string(), vec![s.to_string()]), |
|
109 |
MapType(t) => ConfigEntry("MAP".to_string(), vec![t.to_string()]), |
|
110 |
MapGenerator(g) => ConfigEntry("MAPGEN".to_string(), vec![g.to_string()]), |
|
111 |
MazeSize(s) => ConfigEntry("MAZE_SIZE".to_string(), vec![s.to_string()]), |
|
112 |
Seed(s) => ConfigEntry("SEED".to_string(), vec![s.to_string()]), |
|
113 |
Template(t) => ConfigEntry("TEMPLATE".to_string(), vec![t.to_string()]), |
|
114 |
||
115 |
Ammo(n, None) => ConfigEntry("AMMO".to_string(), vec![n.to_string()]), |
|
116 |
Ammo(n, Some(s)) => ConfigEntry("AMMO".to_string(), vec![n.to_string(), s.to_string()]), |
|
117 |
Scheme(n, None) => ConfigEntry("SCHEME".to_string(), vec![n.to_string()]), |
|
118 |
Scheme(n, Some(s)) => ConfigEntry("SCHEME".to_string(), { |
|
119 |
let mut v = vec![n.to_string()]; |
|
120 |
v.extend(s.into_iter()); |
|
121 |
v |
|
122 |
}), |
|
123 |
Script(s) => ConfigEntry("SCRIPT".to_string(), vec![s.to_string()]), |
|
124 |
Theme(t) => ConfigEntry("THEME".to_string(), vec![t.to_string()]), |
|
125 |
DrawnMap(m) => ConfigEntry("DRAWNMAP".to_string(), vec![m.to_string()]) |
|
126 |
} |
|
127 |
} |
|
128 |
} |
|
129 |
||
13119
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
130 |
impl<'a> HWProtocolMessage { |
12136 | 131 |
pub fn to_raw_protocol(&self) -> String { |
13119
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
132 |
use self::HWProtocolMessage::*; |
13416 | 133 |
match self { |
13119
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
134 |
Ping => "PING\n\n".to_string(), |
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
135 |
Pong => "PONG\n\n".to_string(), |
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
136 |
Quit(None) => format!("QUIT\n\n"), |
13416 | 137 |
Quit(Some(msg)) => format!("QUIT\n{}\n\n", msg), |
138 |
Global(msg) => format!("CMD\nGLOBAL\n{}\n\n", msg), |
|
139 |
Watch(name) => format!("CMD\nWATCH\n{}\n\n", name), |
|
13119
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
140 |
ToggleServerRegisteredOnly => "CMD\nREGISTERED_ONLY\n\n".to_string(), |
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
141 |
SuperPower => "CMD\nSUPER_POWER\n\n".to_string(), |
13416 | 142 |
Info(info) => format!("CMD\nINFO\n{}\n\n", info), |
143 |
Nick(nick) => format!("NICK\n{}\n\n", nick), |
|
13119
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
144 |
Proto(version) => format!("PROTO\n{}\n\n", version), |
13416 | 145 |
Password(p, s) => format!("PASSWORD\n{}\n{}\n\n", p, s), //? |
146 |
Checker(i, n, p) => |
|
13119
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
147 |
format!("CHECKER\n{}\n{}\n{}\n\n", i, n, p), //?, |
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
148 |
List => "LIST\n\n".to_string(), |
13416 | 149 |
Chat(msg) => format!("CHAT\n{}\n\n", msg), |
150 |
CreateRoom(name, None) => |
|
13119
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
151 |
format!("CREATE_ROOM\n{}\n\n", name), |
13416 | 152 |
CreateRoom(name, Some(password)) => |
13119
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
153 |
format!("CREATE_ROOM\n{}\n{}\n\n", name, password), |
13416 | 154 |
JoinRoom(name, None) => |
13119
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
155 |
format!("JOIN\n{}\n\n", name), |
13416 | 156 |
JoinRoom(name, Some(arg)) => |
13119
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
157 |
format!("JOIN\n{}\n{}\n\n", name, arg), |
13416 | 158 |
Follow(name) => |
13119
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
159 |
format!("FOLLOW\n{}\n\n", name), |
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
160 |
//Rnd(Vec<String>), ??? |
13416 | 161 |
Kick(name) => format!("KICK\n{}\n\n", name), |
162 |
Ban(name, reason, time) => |
|
13119
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
163 |
format!("BAN\n{}\n{}\n{}\n\n", name, reason, time), |
13416 | 164 |
BanIP(ip, reason, time) => |
13119
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
165 |
format!("BAN_IP\n{}\n{}\n{}\n\n", ip, reason, time), |
13416 | 166 |
BanNick(nick, reason, time) => |
13119
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
167 |
format!("BAN_NICK\n{}\n{}\n{}\n\n", nick, reason, time), |
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
168 |
BanList => "BANLIST\n\n".to_string(), |
13416 | 169 |
Unban(name) => format!("UNBAN\n{}\n\n", name), |
13119
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
170 |
//SetServerVar(ServerVar), ??? |
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
171 |
GetServerVar => "GET_SERVER_VAR\n\n".to_string(), |
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
172 |
RestartServer => "CMD\nRESTART_SERVER\nYES\n\n".to_string(), |
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
173 |
Stats => "CMD\nSTATS\n\n".to_string(), |
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
174 |
Part(None) => "CMD\nPART\n\n".to_string(), |
13416 | 175 |
Part(Some(msg)) => format!("CMD\nPART\n{}\n\n", msg), |
13119
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
176 |
//Cfg(GameCfg) ?? |
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
177 |
//AddTeam(TeamInfo) ??, |
13416 | 178 |
RemoveTeam(name) => format!("REMOVE_TEAM\n{}\n\n", name), |
13119
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
179 |
//SetHedgehogsNumber(String, u8), ?? |
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
180 |
//SetTeamColor(String, u8), ?? |
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
181 |
ToggleReady => "TOGGLE_READY\n\n".to_string(), |
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
182 |
StartGame => "START_GAME\n\n".to_string(), |
13416 | 183 |
EngineMessage(msg) => format!("EM\n{}\n\n", msg), |
13119
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
184 |
RoundFinished => "ROUNDFINISHED\n\n".to_string(), |
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
185 |
ToggleRestrictJoin => "TOGGLE_RESTRICT_JOINS\n\n".to_string(), |
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
186 |
ToggleRestrictTeams => "TOGGLE_RESTRICT_TEAMS\n\n".to_string(), |
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
187 |
ToggleRegisteredOnly => "TOGGLE_REGISTERED_ONLY\n\n".to_string(), |
13416 | 188 |
RoomName(name) => format!("ROOM_NAME\n{}\n\n", name), |
189 |
Delegate(name) => format!("CMD\nDELEGATE\n{}\n\n", name), |
|
190 |
TeamChat(msg) => format!("TEAMCHAT\n{}\n\n", msg), |
|
13119
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
191 |
MaxTeams(count) => format!("CMD\nMAXTEAMS\n{}\n\n", count) , |
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
192 |
Fix => "CMD\nFIX\n\n".to_string(), |
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
193 |
Unfix => "CMD\nUNFIX\n\n".to_string(), |
13416 | 194 |
Greeting(msg) => format!("CMD\nGREETING\n{}\n\n", msg), |
13119
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
195 |
//CallVote(Option<(String, Option<String>)>) =>, ?? |
13416 | 196 |
Vote(msg) => format!("CMD\nVOTE\n{}\n\n", msg), |
197 |
ForceVote(msg) => format!("CMD\nFORCE\n{}\n\n", msg), |
|
13119
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
198 |
//Save(String, String), ?? |
13416 | 199 |
Delete(room) => format!("CMD\nDELETE\n{}\n\n", room), |
200 |
SaveRoom(room) => format!("CMD\nSAVEROOM\n{}\n\n", room), |
|
201 |
LoadRoom(room) => format!("CMD\nLOADROOM\n{}\n\n", room), |
|
13119
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
202 |
Malformed => "A\nQUICK\nBROWN\nHOG\nJUMPS\nOVER\nTHE\nLAZY\nDOG\n\n".to_string(), |
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
203 |
Empty => "\n\n".to_string(), |
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
204 |
_ => panic!("Protocol message not yet implemented") |
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
205 |
} |
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
206 |
} |
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
207 |
} |
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
208 |
|
13416 | 209 |
macro_rules! const_braces { |
210 |
($e: expr) => { "{}\n" } |
|
211 |
} |
|
212 |
||
213 |
macro_rules! msg { |
|
214 |
[$($part: expr),*] => { |
|
215 |
format!(concat!($(const_braces!($part)),*, "\n"), $($part),*); |
|
216 |
}; |
|
217 |
} |
|
218 |
||
13419 | 219 |
fn construct_message(header: &[&str], msg: &Vec<String>) -> String { |
220 |
let mut v: Vec<_> = header.iter().map(|s| *s).collect(); |
|
221 |
v.extend(msg.iter().map(|s| &s[..])); |
|
222 |
v.push("\n"); |
|
223 |
v.join("\n") |
|
13416 | 224 |
} |
225 |
||
13119
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
226 |
impl HWServerMessage { |
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
227 |
pub fn to_raw_protocol(&self) -> String { |
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
228 |
use self::HWServerMessage::*; |
12136 | 229 |
match self { |
13416 | 230 |
Ping => msg!["PING"], |
231 |
Pong => msg!["PONG"], |
|
232 |
Connected(protocol_version) => msg![ |
|
233 |
"CONNECTED", |
|
234 |
"Hedgewars server http://www.hedgewars.org/", |
|
235 |
protocol_version], |
|
236 |
Bye(msg) => msg!["BYE", msg], |
|
237 |
Nick(nick) => msg!["NICK", nick], |
|
238 |
Proto(proto) => msg!["PROTO", proto], |
|
239 |
LobbyLeft(nick, msg) => msg!["LOBBY:LEFT", nick, msg], |
|
13419 | 240 |
LobbyJoined(nicks) => |
241 |
construct_message(&["LOBBY:JOINED"], &nicks), |
|
242 |
ClientFlags(flags, nicks) => |
|
243 |
construct_message(&["CLIENT_FLAGS", flags], &nicks), |
|
244 |
Rooms(info) => |
|
245 |
construct_message(&["ROOMS"], &info), |
|
246 |
RoomAdd(info) => |
|
247 |
construct_message(&["ROOM", "ADD"], &info), |
|
248 |
RoomJoined(nicks) => |
|
249 |
construct_message(&["JOINED"], &nicks), |
|
13416 | 250 |
RoomLeft(nick, msg) => msg!["LEFT", nick, msg], |
251 |
RoomRemove(name) => msg!["ROOM", "DEL", name], |
|
13419 | 252 |
RoomUpdated(name, info) => |
253 |
construct_message(&["ROOM", "UPD", name], &info), |
|
254 |
TeamAdd(info) => |
|
255 |
construct_message(&["ADD_TEAM"], &info), |
|
256 |
TeamRemove(name) => msg!["REMOVE_TEAM", name], |
|
257 |
TeamAccepted(name) => msg!["TEAM_ACCEPTED", name], |
|
258 |
TeamColor(name, color) => msg!["TEAM_COLOR", name, color], |
|
259 |
HedgehogsNumber(name, number) => msg!["HH_NUM", name, number], |
|
13422 | 260 |
ConfigEntry(name, values) => |
261 |
construct_message(&["CFG", name], &values), |
|
13416 | 262 |
ChatMsg(nick, msg) => msg!["CHAT", nick, msg], |
263 |
ServerMessage(msg) => msg!["SERVER_MESSAGE", msg], |
|
264 |
Warning(msg) => msg!["WARNING", msg], |
|
265 |
Error(msg) => msg!["ERROR", msg], |
|
266 |
_ => msg!["ERROR", "UNIMPLEMENTED"], |
|
12136 | 267 |
} |
268 |
} |
|
269 |
} |