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

Method new_client

server-sent-events/src/broadcast.rs:67–75  ·  view source on GitHub ↗

Registers client with broadcaster, returning an SSE response body.

(&self)

Source from the content-addressed store, hash-verified

65
66 /// Registers client with broadcaster, returning an SSE response body.
67 pub async fn new_client(&self) -> Sse<InfallibleStream<ReceiverStream<sse::Event>>> {
68 let (tx, rx) = mpsc::channel(10);
69
70 tx.send(sse::Data::new("connected").into()).await.unwrap();
71
72 self.inner.lock().clients.push(tx);
73
74 Sse::from_infallible_receiver(rx)
75 }
76
77 /// Broadcasts `msg` to all clients.
78 pub async fn broadcast(&self, msg: &str) {

Callers 1

event_streamFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected