--- a/rust/hedgewars-server/src/server/actions.rs Thu Feb 07 17:02:24 2019 +0300
+++ b/rust/hedgewars-server/src/server/actions.rs Thu Feb 07 17:17:42 2019 +0300
@@ -16,11 +16,17 @@
#[cfg(feature = "official-server")]
use super::database;
+pub enum DestinationRoom {
+ All,
+ Lobby,
+ Room(RoomId),
+}
+
pub enum Destination {
ToId(ClientId),
ToSelf,
ToAll {
- room_id: Option<RoomId>,
+ room_id: DestinationRoom,
protocol: Option<u16>,
skip_self: bool,
},
@@ -48,7 +54,7 @@
pub fn send_all(message: HWServerMessage) -> PendingMessage {
let destination = Destination::ToAll {
- room_id: None,
+ room_id: DestinationRoom::All,
protocol: None,
skip_self: false,
};
@@ -63,7 +69,17 @@
ref mut room_id, ..
} = self.destination
{
- *room_id = Some(clients_room_id)
+ *room_id = DestinationRoom::Room(clients_room_id)
+ }
+ self
+ }
+
+ pub fn in_lobby(mut self) -> PendingMessage {
+ if let Destination::ToAll {
+ ref mut room_id, ..
+ } = self.destination
+ {
+ *room_id = DestinationRoom::Lobby
}
self
}