/// Broadcast a message to all connected clients
Broadcast a message to all connected clients
Broadcast a message to all connected clients
pub fn broadcast<T: NetworkMessage + Clone>(&self, message: T) {
        let serialized_message = bincode::serialize(&message).expect("Couldn't serialize message!");
        for connection in self.established_connections.iter() {
            let packet = NetworkPacket {
                kind: String::from(T::NAME),
                data: serialized_message.clone(),
            };
            match connection.send_message.try_send(packet) {
                Ok(_) => (),
                Err(err) => {
                    warn!("Could not send to client because: {}", err);
                }
            }
        }
    }
pub fn broadcast < T : NetworkMessage + Clone > ( & self , message : T ) { let serialized_message = bincode :: serialize ( & message ) . expect ( " " ) ; for connection in self . established_connections . iter ( ) { let packet = NetworkPacket { kind : String :: from ( T :: NAME ) , data : serialized_message . clone ( ) , } ; match connection . send_message . try_send ( packet ) { Ok ( _ ) => ( ) , Err ( err ) => { warn ! ( " " err ) ; } } } }
Broadcast a message to all connected clients
Broadcast a message to all connected clients
&self
message
T