rust/hedgewars-server/src/handlers/actions.rs
changeset 15543 02f648f7cbe1
parent 15075 e935b1ad23f3
child 15804 747278149393
equal deleted inserted replaced
15542:3b0b6ce76303 15543:02f648f7cbe1
    10     utils::to_engine_msg,
    10     utils::to_engine_msg,
    11 };
    11 };
    12 use rand::{distributions::Uniform, thread_rng, Rng};
    12 use rand::{distributions::Uniform, thread_rng, Rng};
    13 use std::{io, io::Write, iter::once, mem::replace};
    13 use std::{io, io::Write, iter::once, mem::replace};
    14 
    14 
       
    15 #[derive(Clone)]
    15 pub enum DestinationGroup {
    16 pub enum DestinationGroup {
    16     All,
    17     All,
    17     Lobby,
    18     Lobby,
    18     Room(RoomId),
    19     Room(RoomId),
    19     Protocol(u16),
    20     Protocol(u16),
    20 }
    21 }
    21 
    22 
       
    23 #[derive(Clone)]
    22 pub enum Destination {
    24 pub enum Destination {
    23     ToId(ClientId),
    25     ToId(ClientId),
    24     ToIds(Vec<ClientId>),
    26     ToIds(Vec<ClientId>),
    25     ToSelf,
    27     ToSelf,
    26     ToAll {
    28     ToAll {
   110         PendingMessage::send_self(self)
   112         PendingMessage::send_self(self)
   111     }
   113     }
   112     pub fn send_all(self) -> PendingMessage {
   114     pub fn send_all(self) -> PendingMessage {
   113         PendingMessage::send_all(self)
   115         PendingMessage::send_all(self)
   114     }
   116     }
       
   117     pub fn send_to_destination(self, destination: Destination) -> PendingMessage {
       
   118         PendingMessage {
       
   119             destination,
       
   120             message: self,
       
   121         }
       
   122     }
   115 }
   123 }