pub fn send_message(&mut self, room: &str, message: &str, skip_id: usize) {
        let msg = bytestring::ByteString::from(message);
        let ids = self.rooms.get(room).map(|sessions| {
            sessions
                .iter()
                .filter(|id| **id != skip_id)
                .filter_map(|id| self.sessions.get(id).map(|addr| (addr, id)))
                .filter_map(|(addr, id)| {
                    // collect try_send error session ids.
                    addr.send(Message::Text(msg.clone())).err().map(|_| *id)
                })
                .collect::<Vec<usize>>()
        });

        if let Some(ids) = ids {
            // try_send only fail when websocket connection is gone so disconnect them.
            ids.into_iter().for_each(|id| self.disconnect(id));
        }
    }
// Send message to all users in the room
Send message to all users in the room
Send message to all users in the room
pub fn send_message(&mut self, room: &str, message: &str, skip_id: usize) {
        let msg = bytestring::ByteString::from(message);
        let ids = self.rooms.get(room).map(|sessions| {
            sessions
                .iter()
                .filter(|id| **id != skip_id)
                .filter_map(|id| self.sessions.get(id).map(|addr| (addr, id)))
                .filter_map(|(addr, id)| {
                    // collect try_send error session ids.
                    addr.send(Message::Text(msg.clone())).err().map(|_| *id)
                })
                .collect::<Vec<usize>>()
        });
        if let Some(ids) = ids {
            // try_send only fail when websocket connection is gone so disconnect them.
            ids.into_iter().for_each(|id| self.disconnect(id));
        }
    }
pub fn send_message ( & mut self , room : & str , message : & str , skip_id : usize ) { let msg = bytestring :: ByteString :: from ( message ) ; let ids = self . rooms . get ( room ) . map ( | sessions | { sessions . iter ( ) . filter ( | id | * * id != skip_id ) . filter_map ( | id | self . sessions . get ( id ) . map ( | addr | ( addr , id ) ) ) . filter_map ( | ( addr , id ) | { // collect try_send error session ids. addr . send ( Message :: Text ( msg . clone ( ) ) ) . err ( ) . map ( | _ | * id ) } ) . collect :: < Vec < usize > > ( ) } ) ; if let Some ( ids ) = ids { // try_send only fail when websocket connection is gone so disconnect them. ids . into_iter ( ) . for_each ( | id | self . disconnect ( id ) ) ; } }
Send message to all users in the room
Send message to all users in the room
&mut self
room
&str
message
&str
skip_id
usize