Skip to main content

open_stream

Function open_stream 

Source
fn open_stream(
    state: &TransportState,
    updates: &mut Option<(UnboundedReceiver<SeatUpdate>, bool)>,
    answering: bool,
) -> Vec<SeatUpdate>
Expand description

This connection’s stream from the core, opened when the client first subscribes and registered with the role that subscribe declares.

A later subscribe that declares answering REPLACES it - a client is not held to a role it announced before it had decided - and the role only ever goes one way while a connection lives: a stream is opened with the strongest role the client has declared so far, so a later observing subscribe leaves the answering one in place.

Whatever the replaced stream had queued is handed back, because the queue is not only about the subject just asked for: it can hold news about a seat this client is already watching, and dropping the receiver drops that news silently.

Every caller gets a stream of its own, so a second client attaches beside the first rather than stealing its events, and dropping the socket drops this with it - which is what keeps a subscription from outliving its connection.

Nothing is missed by waiting for a subscribe: a connection with no subscribed subject forwards no update anyway.