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

Method send_message

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

Send message to all other users in current room. `conn` is used to find current room and prevent messages sent by a connection also being received by it.

(&self, conn: ConnId, msg: impl Into<Msg>)

Source from the content-addressed store, hash-verified

107 /// `conn` is used to find current room and prevent messages sent by a connection also being
108 /// received by it.
109 async fn send_message(&self, conn: ConnId, msg: impl Into<Msg>) {
110 if let Some(room) = self
111 .rooms
112 .iter()
113 .find_map(|(room, participants)| participants.contains(&conn).then_some(room))
114 {
115 self.send_system_message(room, conn, msg).await;
116 };
117 }
118
119 /// Register new session and assign unique ID to this session
120 async fn connect(&mut self, tx: mpsc::UnboundedSender<Msg>) -> ConnId {

Callers 2

runMethod · 0.45
process_text_msgFunction · 0.45

Calls 1

send_system_messageMethod · 0.80

Tested by

no test coverage detected