MCPcopy Create free account
hub / github.com/actix/examples / send_system_message

Method send_system_message

websockets/chat-actorless/src/server.rs:90–103  ·  view source on GitHub ↗

Send message to users in a room. `skip` is used to prevent messages triggered by a connection also being received by it.

(&self, room: &str, skip: ConnId, msg: impl Into<Msg>)

Source from the content-addressed store, hash-verified

88 ///
89 /// `skip` is used to prevent messages triggered by a connection also being received by it.
90 async fn send_system_message(&self, room: &str, skip: ConnId, msg: impl Into<Msg>) {
91 if let Some(sessions) = self.rooms.get(room) {
92 let msg = msg.into();
93
94 for conn_id in sessions {
95 if *conn_id != skip
96 && let Some(tx) = self.sessions.get(conn_id)
97 {
98 // errors if client disconnected abruptly and hasn't been timed-out yet
99 let _ = tx.send(msg.clone());
100 }
101 }
102 }
103 }
104
105 /// Send message to all other users in current room.
106 ///

Callers 4

send_messageMethod · 0.80
connectMethod · 0.80
disconnectMethod · 0.80
join_roomMethod · 0.80

Calls 1

getMethod · 0.80

Tested by

no test coverage detected