diff -r 6a2e13e36b7f -r 25c564f77b7d rust/hedgewars-server/src/server/actions.rs --- 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, + room_id: DestinationRoom, protocol: Option, 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 }