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