pub struct Connection { /* private fields */ }Expand description
A typed subscriber to one room, addressable by its ConnId. It merges the
room’s broadcast fan-out with events RoomHandle::send_event delivers to it
privately, decoding each into a typed Event. Dropping it unregisters the
targeted channel from the room actor — the RAII unsubscribe handle, the same
pattern Rivet’s actor.on(...) teardown gives you.
Non-event frames (presence deltas, DocSync blobs, raw non-envelope
publish_event values) are skipped by recv, never surfaced as bogus events;
consumers that need the raw wire use RoomHandle::subscribe instead.
Implementations§
Source§impl Connection
impl Connection
Sourcepub fn id(&self) -> ConnId
pub fn id(&self) -> ConnId
This connection’s process-unique id — the address for
RoomHandle::send_event.
Sourcepub async fn recv(&mut self) -> Option<Event>
pub async fn recv(&mut self) -> Option<Event>
Await the next typed Event for this connection, from either the room
broadcast or a targeted send_event. Non-event frames are skipped. Returns
None once both delivery paths are permanently closed (the room actor exited
and the broadcast channel is drained), so it drives a while let loop.