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

Method started

websockets/chat/src/session.rs:64–88  ·  view source on GitHub ↗

Method is called on actor start. We register ws session with ChatServer

(&mut self, ctx: &mut Self::Context)

Source from the content-addressed store, hash-verified

62 }
63
64 outgoing = inbox.recv() => {
65 match outgoing {
66 Some(text) => if session.text(text).await.is_err() { break None; },
67 None => break None,
68 }
69 }
70
71 _ = timer.tick() => {
72 if heartbeat.elapsed() > CLIENT_TIMEOUT || session.ping(b"").await.is_err() {
73 break None;
74 }
75 }
76 }
77 };
78
79 let _ = server.cast(Command::Disconnect { id });
80
81 // A slow peer must not hold up shutdown while the close frame is queued.
82 let _ = session.close(reason).timeout(Duration::from_secs(1)).await;
83}
84
85async fn process_text(
86 server: &ActorRef<Command>,
87 session: &mut actix_ws::Session,
88 id: u64,
89 room: &mut String,
90 name: &mut Option<String>,
91 text: &str,

Callers

nothing calls this directly

Calls 3

waitMethod · 0.80
stopMethod · 0.80
hbMethod · 0.45

Tested by

no test coverage detected