author | alfadur |
Tue, 09 Apr 2019 21:08:35 +0300 | |
changeset 14800 | f43ab2bd76ae |
parent 14718 | f64e21f164a5 |
child 14803 | 50fcef24003f |
permissions | -rw-r--r-- |
14478 | 1 |
use crate::server::coretypes::{GameCfg, HedgehogInfo, ServerVar, TeamInfo, VoteType}; |
2 |
use std::{convert::From, iter::once, ops}; |
|
12130 | 3 |
|
13119
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
4 |
#[derive(PartialEq, Eq, Clone, Debug)] |
12142
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
5 |
pub enum HWProtocolMessage { |
14718 | 6 |
// common messages |
12130 | 7 |
Ping, |
8 |
Pong, |
|
12142
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
9 |
Quit(Option<String>), |
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
10 |
Global(String), |
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
11 |
Watch(String), |
12130 | 12 |
ToggleServerRegisteredOnly, |
13 |
SuperPower, |
|
12142
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
14 |
Info(String), |
14718 | 15 |
// anteroom messages |
12142
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
16 |
Nick(String), |
13486 | 17 |
Proto(u16), |
12142
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
18 |
Password(String, String), |
13771 | 19 |
Checker(u16, String, String), |
14718 | 20 |
// lobby messages |
12130 | 21 |
List, |
12142
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
22 |
Chat(String), |
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
23 |
CreateRoom(String, Option<String>), |
13416 | 24 |
JoinRoom(String, Option<String>), |
12142
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
25 |
Follow(String), |
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
26 |
Rnd(Vec<String>), |
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
27 |
Kick(String), |
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
28 |
Ban(String, String, u32), |
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
29 |
BanIP(String, String, u32), |
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
30 |
BanNick(String, String, u32), |
12130 | 31 |
BanList, |
12142
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
32 |
Unban(String), |
12130 | 33 |
SetServerVar(ServerVar), |
34 |
GetServerVar, |
|
35 |
RestartServer, |
|
36 |
Stats, |
|
14718 | 37 |
// room messages |
12142
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
38 |
Part(Option<String>), |
12130 | 39 |
Cfg(GameCfg), |
13500 | 40 |
AddTeam(Box<TeamInfo>), |
12142
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
41 |
RemoveTeam(String), |
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
42 |
SetHedgehogsNumber(String, u8), |
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
43 |
SetTeamColor(String, u8), |
12130 | 44 |
ToggleReady, |
45 |
StartGame, |
|
12142
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
46 |
EngineMessage(String), |
12130 | 47 |
RoundFinished, |
48 |
ToggleRestrictJoin, |
|
49 |
ToggleRestrictTeams, |
|
50 |
ToggleRegisteredOnly, |
|
12142
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
51 |
RoomName(String), |
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
52 |
Delegate(String), |
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
53 |
TeamChat(String), |
12130 | 54 |
MaxTeams(u8), |
55 |
Fix, |
|
56 |
Unfix, |
|
12142
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
57 |
Greeting(String), |
13450 | 58 |
CallVote(Option<VoteType>), |
59 |
Vote(bool), |
|
60 |
ForceVote(bool), |
|
12142
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
61 |
Save(String, String), |
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
62 |
Delete(String), |
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
63 |
SaveRoom(String), |
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
64 |
LoadRoom(String), |
12137
193dfdcb0620
- Use logging facilities instead of plain println!
unc0rr
parents:
12136
diff
changeset
|
65 |
Malformed, |
193dfdcb0620
- Use logging facilities instead of plain println!
unc0rr
parents:
12136
diff
changeset
|
66 |
Empty, |
12130 | 67 |
} |
12131 | 68 |
|
13416 | 69 |
#[derive(Debug)] |
13119
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
70 |
pub enum HWServerMessage { |
12142
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
71 |
Ping, |
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
72 |
Pong, |
13119
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
73 |
Bye(String), |
14800
f43ab2bd76ae
add a thread for internal server IO and implement account checking with it
alfadur
parents:
14718
diff
changeset
|
74 |
|
13119
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
75 |
Nick(String), |
13486 | 76 |
Proto(u16), |
14800
f43ab2bd76ae
add a thread for internal server IO and implement account checking with it
alfadur
parents:
14718
diff
changeset
|
77 |
AskPassword(String), |
f43ab2bd76ae
add a thread for internal server IO and implement account checking with it
alfadur
parents:
14718
diff
changeset
|
78 |
|
13774 | 79 |
ServerAuth(String), |
13416 | 80 |
LobbyLeft(String, String), |
13119
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
81 |
LobbyJoined(Vec<String>), |
14478 | 82 |
ChatMsg { nick: String, msg: String }, |
13119
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
83 |
ClientFlags(String, Vec<String>), |
13416 | 84 |
Rooms(Vec<String>), |
85 |
RoomAdd(Vec<String>), |
|
86 |
RoomJoined(Vec<String>), |
|
87 |
RoomLeft(String, String), |
|
88 |
RoomRemove(String), |
|
89 |
RoomUpdated(String, Vec<String>), |
|
13419 | 90 |
TeamAdd(Vec<String>), |
91 |
TeamRemove(String), |
|
92 |
TeamAccepted(String), |
|
93 |
TeamColor(String, u8), |
|
94 |
HedgehogsNumber(String, u8), |
|
13422 | 95 |
ConfigEntry(String, Vec<String>), |
13450 | 96 |
Kicked, |
13423 | 97 |
RunGame, |
13428 | 98 |
ForwardEngineMessage(Vec<String>), |
13423 | 99 |
RoundFinished, |
13419 | 100 |
|
13416 | 101 |
ServerMessage(String), |
13775 | 102 |
Notice(String), |
13119
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
103 |
Warning(String), |
13416 | 104 |
Error(String), |
12142
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
105 |
Connected(u32), |
4d7d41be1993
Start refactoring path from getting message from client to reacting to it
unc0rr
parents:
12141
diff
changeset
|
106 |
Unreachable, |
13775 | 107 |
|
108 |
//Deprecated messages |
|
14478 | 109 |
LegacyReady(bool, Vec<String>), |
12131 | 110 |
} |
12136 | 111 |
|
14478 | 112 |
pub fn server_chat(msg: String) -> HWServerMessage { |
113 |
HWServerMessage::ChatMsg { |
|
114 |
nick: "[server]".to_string(), |
|
115 |
msg, |
|
116 |
} |
|
13450 | 117 |
} |
118 |
||
13422 | 119 |
impl GameCfg { |
13439 | 120 |
pub fn to_protocol(&self) -> (String, Vec<String>) { |
13666 | 121 |
use crate::server::coretypes::GameCfg::*; |
13422 | 122 |
match self { |
13439 | 123 |
FeatureSize(s) => ("FEATURE_SIZE".to_string(), vec![s.to_string()]), |
124 |
MapType(t) => ("MAP".to_string(), vec![t.to_string()]), |
|
125 |
MapGenerator(g) => ("MAPGEN".to_string(), vec![g.to_string()]), |
|
126 |
MazeSize(s) => ("MAZE_SIZE".to_string(), vec![s.to_string()]), |
|
127 |
Seed(s) => ("SEED".to_string(), vec![s.to_string()]), |
|
128 |
Template(t) => ("TEMPLATE".to_string(), vec![t.to_string()]), |
|
13422 | 129 |
|
13439 | 130 |
Ammo(n, None) => ("AMMO".to_string(), vec![n.to_string()]), |
131 |
Ammo(n, Some(s)) => ("AMMO".to_string(), vec![n.to_string(), s.to_string()]), |
|
13775 | 132 |
Scheme(n, s) if s.is_empty() => ("SCHEME".to_string(), vec![n.to_string()]), |
133 |
Scheme(n, s) => ("SCHEME".to_string(), { |
|
13422 | 134 |
let mut v = vec![n.to_string()]; |
13439 | 135 |
v.extend(s.clone().into_iter()); |
13422 | 136 |
v |
137 |
}), |
|
13439 | 138 |
Script(s) => ("SCRIPT".to_string(), vec![s.to_string()]), |
139 |
Theme(t) => ("THEME".to_string(), vec![t.to_string()]), |
|
14478 | 140 |
DrawnMap(m) => ("DRAWNMAP".to_string(), vec![m.to_string()]), |
13422 | 141 |
} |
142 |
} |
|
13439 | 143 |
|
144 |
pub fn to_server_msg(&self) -> HWServerMessage { |
|
145 |
use self::HWServerMessage::ConfigEntry; |
|
146 |
let (name, args) = self.to_protocol(); |
|
147 |
HWServerMessage::ConfigEntry(name, args) |
|
148 |
} |
|
13422 | 149 |
} |
150 |
||
13416 | 151 |
macro_rules! const_braces { |
14478 | 152 |
($e: expr) => { |
153 |
"{}\n" |
|
154 |
}; |
|
13416 | 155 |
} |
156 |
||
157 |
macro_rules! msg { |
|
158 |
[$($part: expr),*] => { |
|
159 |
format!(concat!($(const_braces!($part)),*, "\n"), $($part),*); |
|
160 |
}; |
|
161 |
} |
|
162 |
||
13713 | 163 |
#[cfg(test)] |
13439 | 164 |
macro_rules! several { |
165 |
[$part: expr] => { once($part) }; |
|
166 |
[$part: expr, $($other: expr),*] => { once($part).chain(several![$($other),*]) }; |
|
167 |
} |
|
168 |
||
13433
fb104e150878
Implement to_raw_protocol for Rnd and enable tests. Add cargo/rls build artifacts to .gitignore
Marcin Mielniczuk <marmistrz.dev@zoho.eu>
parents:
13432
diff
changeset
|
169 |
impl HWProtocolMessage { |
fb104e150878
Implement to_raw_protocol for Rnd and enable tests. Add cargo/rls build artifacts to .gitignore
Marcin Mielniczuk <marmistrz.dev@zoho.eu>
parents:
13432
diff
changeset
|
170 |
/** Converts the message to a raw `String`, which can be sent over the network. |
fb104e150878
Implement to_raw_protocol for Rnd and enable tests. Add cargo/rls build artifacts to .gitignore
Marcin Mielniczuk <marmistrz.dev@zoho.eu>
parents:
13432
diff
changeset
|
171 |
* |
fb104e150878
Implement to_raw_protocol for Rnd and enable tests. Add cargo/rls build artifacts to .gitignore
Marcin Mielniczuk <marmistrz.dev@zoho.eu>
parents:
13432
diff
changeset
|
172 |
* This is the inverse of the `message` parser. |
fb104e150878
Implement to_raw_protocol for Rnd and enable tests. Add cargo/rls build artifacts to .gitignore
Marcin Mielniczuk <marmistrz.dev@zoho.eu>
parents:
13432
diff
changeset
|
173 |
*/ |
13713 | 174 |
#[cfg(test)] |
13433
fb104e150878
Implement to_raw_protocol for Rnd and enable tests. Add cargo/rls build artifacts to .gitignore
Marcin Mielniczuk <marmistrz.dev@zoho.eu>
parents:
13432
diff
changeset
|
175 |
pub(crate) fn to_raw_protocol(&self) -> String { |
13432 | 176 |
use self::HWProtocolMessage::*; |
177 |
match self { |
|
178 |
Ping => msg!["PING"], |
|
179 |
Pong => msg!["PONG"], |
|
180 |
Quit(None) => msg!["QUIT"], |
|
181 |
Quit(Some(msg)) => msg!["QUIT", msg], |
|
182 |
Global(msg) => msg!["CMD", format!("GLOBAL {}", msg)], |
|
183 |
Watch(name) => msg!["CMD", format!("WATCH {}", name)], |
|
184 |
ToggleServerRegisteredOnly => msg!["CMD", "REGISTERED_ONLY"], |
|
14478 | 185 |
SuperPower => msg!["CMD", "SUPER_POWER"], |
13432 | 186 |
Info(info) => msg!["CMD", format!("INFO {}", info)], |
187 |
Nick(nick) => msg!("NICK", nick), |
|
188 |
Proto(version) => msg!["PROTO", version], |
|
189 |
Password(p, s) => msg!["PASSWORD", p, s], |
|
190 |
Checker(i, n, p) => msg!["CHECKER", i, n, p], |
|
191 |
List => msg!["LIST"], |
|
192 |
Chat(msg) => msg!["CHAT", msg], |
|
193 |
CreateRoom(name, None) => msg!["CREATE_ROOM", name], |
|
14478 | 194 |
CreateRoom(name, Some(password)) => msg!["CREATE_ROOM", name, password], |
13432 | 195 |
JoinRoom(name, None) => msg!["JOIN_ROOM", name], |
14478 | 196 |
JoinRoom(name, Some(password)) => msg!["JOIN_ROOM", name, password], |
13432 | 197 |
Follow(name) => msg!["FOLLOW", name], |
14478 | 198 |
Rnd(args) => { |
199 |
if args.is_empty() { |
|
200 |
msg!["CMD", "RND"] |
|
201 |
} else { |
|
202 |
msg!["CMD", format!("RND {}", args.join(" "))] |
|
203 |
} |
|
204 |
} |
|
13432 | 205 |
Kick(name) => msg!["KICK", name], |
206 |
Ban(name, reason, time) => msg!["BAN", name, reason, time], |
|
207 |
BanIP(ip, reason, time) => msg!["BAN_IP", ip, reason, time], |
|
14478 | 208 |
BanNick(nick, reason, time) => msg!("BAN_NICK", nick, reason, time), |
13432 | 209 |
BanList => msg!["BANLIST"], |
210 |
Unban(name) => msg!["UNBAN", name], |
|
211 |
//SetServerVar(ServerVar), ??? |
|
212 |
GetServerVar => msg!["GET_SERVER_VAR"], |
|
213 |
RestartServer => msg!["CMD", "RESTART_SERVER YES"], |
|
214 |
Stats => msg!["CMD", "STATS"], |
|
215 |
Part(None) => msg!["PART"], |
|
216 |
Part(Some(msg)) => msg!["PART", msg], |
|
13439 | 217 |
Cfg(config) => { |
218 |
let (name, args) = config.to_protocol(); |
|
219 |
msg!["CFG", name, args.join("\n")] |
|
14478 | 220 |
} |
221 |
AddTeam(info) => msg![ |
|
222 |
"ADD_TEAM", |
|
223 |
info.name, |
|
224 |
info.color, |
|
225 |
info.grave, |
|
226 |
info.fort, |
|
227 |
info.voice_pack, |
|
228 |
info.flag, |
|
229 |
info.difficulty, |
|
230 |
info.hedgehogs |
|
231 |
.iter() |
|
232 |
.flat_map(|h| several![&h.name[..], &h.hat[..]]) |
|
233 |
.collect::<Vec<_>>() |
|
234 |
.join("\n") |
|
235 |
], |
|
13432 | 236 |
RemoveTeam(name) => msg!["REMOVE_TEAM", name], |
13439 | 237 |
SetHedgehogsNumber(team, number) => msg!["HH_NUM", team, number], |
238 |
SetTeamColor(team, color) => msg!["TEAM_COLOR", team, color], |
|
13432 | 239 |
ToggleReady => msg!["TOGGLE_READY"], |
240 |
StartGame => msg!["START_GAME"], |
|
241 |
EngineMessage(msg) => msg!["EM", msg], |
|
242 |
RoundFinished => msg!["ROUNDFINISHED"], |
|
243 |
ToggleRestrictJoin => msg!["TOGGLE_RESTRICT_JOINS"], |
|
244 |
ToggleRestrictTeams => msg!["TOGGLE_RESTRICT_TEAMS"], |
|
245 |
ToggleRegisteredOnly => msg!["TOGGLE_REGISTERED_ONLY"], |
|
246 |
RoomName(name) => msg!["ROOM_NAME", name], |
|
247 |
Delegate(name) => msg!["CMD", format!("DELEGATE {}", name)], |
|
248 |
TeamChat(msg) => msg!["TEAMCHAT", msg], |
|
14478 | 249 |
MaxTeams(count) => msg!["CMD", format!("MAXTEAMS {}", count)], |
13432 | 250 |
Fix => msg!["CMD", "FIX"], |
251 |
Unfix => msg!["CMD", "UNFIX"], |
|
252 |
Greeting(msg) => msg!["CMD", format!("GREETING {}", msg)], |
|
253 |
//CallVote(Option<(String, Option<String>)>) =>, ?? |
|
14478 | 254 |
Vote(msg) => msg!["CMD", format!("VOTE {}", if *msg { "YES" } else { "NO" })], |
255 |
ForceVote(msg) => msg!["CMD", format!("FORCE {}", if *msg { "YES" } else { "NO" })], |
|
13528 | 256 |
Save(name, location) => msg!["CMD", format!("SAVE {} {}", name, location)], |
257 |
Delete(name) => msg!["CMD", format!("DELETE {}", name)], |
|
258 |
SaveRoom(name) => msg!["CMD", format!("SAVEROOM {}", name)], |
|
259 |
LoadRoom(name) => msg!["CMD", format!("LOADROOM {}", name)], |
|
13432 | 260 |
Malformed => msg!["A", "QUICK", "BROWN", "HOG", "JUMPS", "OVER", "THE", "LAZY", "DOG"], |
261 |
Empty => msg![""], |
|
14478 | 262 |
_ => panic!("Protocol message not yet implemented"), |
13432 | 263 |
} |
264 |
} |
|
265 |
} |
|
266 |
||
13500 | 267 |
fn construct_message(header: &[&str], msg: &[String]) -> String { |
14371 | 268 |
let mut v: Vec<_> = header.iter().cloned().collect(); |
13419 | 269 |
v.extend(msg.iter().map(|s| &s[..])); |
270 |
v.push("\n"); |
|
271 |
v.join("\n") |
|
13416 | 272 |
} |
273 |
||
13119
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
274 |
impl HWServerMessage { |
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
275 |
pub fn to_raw_protocol(&self) -> String { |
1e39b8749072
separated the server logic from all the async io mess.
alfadur
parents:
12147
diff
changeset
|
276 |
use self::HWServerMessage::*; |
12136 | 277 |
match self { |
13416 | 278 |
Ping => msg!["PING"], |
279 |
Pong => msg!["PONG"], |
|
280 |
Connected(protocol_version) => msg![ |
|
281 |
"CONNECTED", |
|
13667 | 282 |
"Hedgewars server https://www.hedgewars.org/", |
14478 | 283 |
protocol_version |
284 |
], |
|
13416 | 285 |
Bye(msg) => msg!["BYE", msg], |
286 |
Nick(nick) => msg!["NICK", nick], |
|
287 |
Proto(proto) => msg!["PROTO", proto], |
|
14800
f43ab2bd76ae
add a thread for internal server IO and implement account checking with it
alfadur
parents:
14718
diff
changeset
|
288 |
AskPassword(salt) => msg!["ASKPASSWORD", salt], |
13774 | 289 |
ServerAuth(hash) => msg!["SERVER_AUTH", hash], |
13416 | 290 |
LobbyLeft(nick, msg) => msg!["LOBBY:LEFT", nick, msg], |
14478 | 291 |
LobbyJoined(nicks) => construct_message(&["LOBBY:JOINED"], &nicks), |
292 |
ClientFlags(flags, nicks) => construct_message(&["CLIENT_FLAGS", flags], &nicks), |
|
293 |
Rooms(info) => construct_message(&["ROOMS"], &info), |
|
294 |
RoomAdd(info) => construct_message(&["ROOM", "ADD"], &info), |
|
295 |
RoomJoined(nicks) => construct_message(&["JOINED"], &nicks), |
|
13416 | 296 |
RoomLeft(nick, msg) => msg!["LEFT", nick, msg], |
297 |
RoomRemove(name) => msg!["ROOM", "DEL", name], |
|
14478 | 298 |
RoomUpdated(name, info) => construct_message(&["ROOM", "UPD", name], &info), |
299 |
TeamAdd(info) => construct_message(&["ADD_TEAM"], &info), |
|
13419 | 300 |
TeamRemove(name) => msg!["REMOVE_TEAM", name], |
301 |
TeamAccepted(name) => msg!["TEAM_ACCEPTED", name], |
|
302 |
TeamColor(name, color) => msg!["TEAM_COLOR", name, color], |
|
303 |
HedgehogsNumber(name, number) => msg!["HH_NUM", name, number], |
|
14478 | 304 |
ConfigEntry(name, values) => construct_message(&["CFG", name], &values), |
13450 | 305 |
Kicked => msg!["KICKED"], |
13423 | 306 |
RunGame => msg!["RUN_GAME"], |
14478 | 307 |
ForwardEngineMessage(em) => construct_message(&["EM"], &em), |
13423 | 308 |
RoundFinished => msg!["ROUND_FINISHED"], |
14478 | 309 |
ChatMsg { nick, msg } => msg!["CHAT", nick, msg], |
13416 | 310 |
ServerMessage(msg) => msg!["SERVER_MESSAGE", msg], |
13775 | 311 |
Notice(msg) => msg!["NOTICE", msg], |
13416 | 312 |
Warning(msg) => msg!["WARNING", msg], |
313 |
Error(msg) => msg!["ERROR", msg], |
|
13775 | 314 |
|
14478 | 315 |
LegacyReady(is_ready, nicks) => { |
316 |
construct_message(&[if *is_ready { "READY" } else { "NOT_READY" }], &nicks) |
|
317 |
} |
|
13775 | 318 |
|
13416 | 319 |
_ => msg!["ERROR", "UNIMPLEMENTED"], |
12136 | 320 |
} |
321 |
} |
|
322 |
} |