struct WsConn {
socket: WebSocket,
state: AppState,
engine: Arc<WshRpcEngine>,
conn_id: String,
priority_rx: Receiver<Value>,
background_rx: Receiver<Value>,
drops: Arc<LaneDrops>,
pending_priority: VecDeque<Value>,
bus_rx: Option<UnboundedReceiver<BusMessage>>,
bus_agent_id: Option<String>,
}Expand description
The egress lanes’ receivers and per-connection state that the select! loop in
handle_ws_connection mutates, so each branch is a method instead of an inline block.
A method returns true when the connection should end.
Fields§
§socket: WebSocket§state: AppState§engine: Arc<WshRpcEngine>§conn_id: String§priority_rx: Receiver<Value>§background_rx: Receiver<Value>§drops: Arc<LaneDrops>§pending_priority: VecDeque<Value>Fairly-ordered priority-lane events awaiting their turn, sent one per loop iteration
(on_priority_event, then flush_one_priority). Forwarding a whole drained batch inside
one select! branch body would starve socket.recv() (this connection’s OWN keystrokes)
for the batch, since select! re-polls siblings only when a body returns; one event per
iteration keeps each send interleaved with a fresh socket.recv() poll, while the batch
keeps its fair pane ordering.
bus_rx: Option<UnboundedReceiver<BusMessage>>Activated when a pane sends bus:register.
bus_agent_id: Option<String>Implementations§
Source§impl WsConn
impl WsConn
Sourceasync fn send_json(&mut self, value: &Value) -> bool
async fn send_json(&mut self, value: &Value) -> bool
Send one JSON frame. Returns true if the send failed.
Sourceasync fn on_client_message(
&mut self,
msg: Option<Result<Message, Error>>,
) -> bool
async fn on_client_message( &mut self, msg: Option<Result<Message, Error>>, ) -> bool
The client’s own traffic: keystrokes and commands (wscommand), pings, close.
Sourceasync fn on_rpc_output(&mut self, rpc_msg: RpcMessage) -> bool
async fn on_rpc_output(&mut self, rpc_msg: RpcMessage) -> bool
An RPC engine reply, wrapped as eventtype: rpc.
Sourceasync fn on_bus_message(&mut self, bus_msg: BusMessage) -> bool
async fn on_bus_message(&mut self, bus_msg: BusMessage) -> bool
A MessageBus message, for a connection registered as an agent.
Sourceasync fn on_priority_event(&mut self, event: Value) -> bool
async fn on_priority_event(&mut self, event: Value) -> bool
Priority event lane → WebSocket. Two sources feed it:
- MPS Broker (via EventBusBridge) — already wrapped as { eventtype: “rpc”, data: { command: “eventrecv”, data: MuxEvent } }
- Direct broadcasts (e.g., SetMeta’s obj:update) — raw { eventtype: “waveobj:update”, oref: “block:xxx”, data: … } This carries terminal echo output and all interactive events.
Fairness: this lane is shared by EVERY pane on the connection, not
just one. A single FIFO here means a noisy pane (heavy PTY output)
can queue an unbounded number of frames ahead of a different pane’s
own keystroke echo, which arrives in the same channel. Draining all
immediately-available events and round-robining them by pane (see
fair_drain_priority) bounds that delay to one “round” per distinct
active pane instead of the length of the noisy pane’s backlog. See
docs/analysis/ANALYSIS_CROSS_PANE_INPUT_DELAY_UNDER_OUTPUT_LOAD_2026_09_04.md.
Only called when pending_priority is empty: while it is still being flushed (one per
iteration), the lane stays unread so we don’t pull more out of priority_rx than we have
finished sending.
Sourceasync fn flush_one_priority(&mut self) -> bool
async fn flush_one_priority(&mut self) -> bool
Flush one fairly-ordered priority event per iteration: a branch guarded on
pending_priority being non-empty, see its declaration for why it is not a loop.
Sourceasync fn on_background_event(&mut self, first_bg: Value) -> bool
async fn on_background_event(&mut self, first_bg: Value) -> bool
Background event lane → WebSocket. Droppable perf telemetry (sysinfo/blockstats) only; serviced when the priority lanes are momentarily idle, so it can never delay a keystroke echo.
Tradeoff of the loop’s biased;: a SUSTAINED priority-lane flood (! yes pumping terminal
output) keeps the priority branches ready, so telemetry queues here until the flood
pauses. The lane is bounded (BACKGROUND_LANE_CAPACITY, drop-on-full: see
eventbus.rs), so a starvation long enough to fill it drops new readings instead of
growing commit; fine for ~1/s telemetry. Everything immediately available is coalesced to
the latest reading per (event-name:scope) key before forwarding, so the flush is at most
1 sysinfo + 1 blockstats per open block, not a burst of stale frames the browser processes
back-to-back ahead of queued keypresses.
See SPEC_TERMINAL_INPUT_PRIORITY_OVER_SYSINFO_2026_06_16.md §4.2.
Sourceasync fn report_drops(&mut self) -> bool
async fn report_drops(&mut self) -> bool
Tell the client about dropped events once the priority lane has drained.
Sourceasync fn on_ping_tick(&mut self) -> bool
async fn on_ping_tick(&mut self) -> bool
Keepalive: a drop report if one is due, then a ping carrying the server time.
Auto Trait Implementations§
impl !Freeze for WsConn
impl !RefUnwindSafe for WsConn
impl !Sync for WsConn
impl !UnwindSafe for WsConn
impl Send for WsConn
impl Unpin for WsConn
impl UnsafeUnpin for WsConn
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more