pub struct EventBus {
watches: Mutex<HashMap<String, WindowWatchData>>,
}Expand description
Global event bus for dispatching WebSocket events to connected clients.
Fields§
§watches: Mutex<HashMap<String, WindowWatchData>>Implementations§
Source§impl EventBus
impl EventBus
pub fn new() -> Self
Sourcepub fn register_ws(&self, conn_id: &str, tab_id: &str) -> WsReceivers
pub fn register_ws(&self, conn_id: &str, tab_id: &str) -> WsReceivers
Register a WebSocket connection for receiving events. Returns the priority + background receiver pair for the connection.
Sourcepub fn unregister_ws(&self, conn_id: &str)
pub fn unregister_ws(&self, conn_id: &str)
Unregister a WebSocket connection.
Sourcepub fn has_connections_for(&self, tab_id: &str) -> bool
pub fn has_connections_for(&self, tab_id: &str) -> bool
Check if any connections exist for a given window/tab ID.
Sourcepub async fn wait_for_connection(&self, tab_id: &str, timeout: Duration) -> bool
pub async fn wait_for_connection(&self, tab_id: &str, timeout: Duration) -> bool
Wait for a connection to appear for the given tab_id (with timeout).
Sourcepub fn send_value_to_conn_lane(&self, conn_id: &str, data: Value, lane: Lane)
pub fn send_value_to_conn_lane(&self, conn_id: &str, data: Value, lane: Lane)
[Self::send_to_conn_lane] for an event already built as the wire
Value — for callers that would otherwise serialize a payload into a
WSEventType and have it serialized a second time here.
Sourcepub fn broadcast_event(&self, event: &WSEventType)
pub fn broadcast_event(&self, event: &WSEventType)
Broadcast an event to all connected WebSocket clients, on the priority lane.
Sourcepub fn typed_ws_event<E: Event>(
payload: &E::Payload,
oref: impl Into<String>,
) -> WSEventType
pub fn typed_ws_event<E: Event>( payload: &E::Payload, oref: impl Into<String>, ) -> WSEventType
A typed event as a raw event-bus frame: eventtype is its name and oref its scope, for
a caller that sends through broadcast_event or a lane rather than the broker.
websocket.rs::forward_event wraps it as the eventrecv frame the renderer reads.
Sourcepub fn typed_frame<E: Event>(payload: &E::Payload) -> Value
pub fn typed_frame<E: Event>(payload: &E::Payload) -> Value
A typed event as the frame srv writes to one WebSocket itself (srvinfo and config on
connect): the same rpc/eventrecv frame a broadcast sends.
Sourcepub fn broadcast_typed<E: Event>(&self, payload: &E::Payload)
pub fn broadcast_typed<E: Event>(&self, payload: &E::Payload)
Broadcast a typed event (mps_events) to every connection directly, not through the
broker: no scopes, nothing persisted. The same rpc/eventrecv frame a broker event
gets (a serialized MuxEvent omits its empty scopes, sender and persist).
Sourcepub fn broadcast_mux_obj_updates(&self, updates: &[MuxObjUpdate])
pub fn broadcast_mux_obj_updates(&self, updates: &[MuxObjUpdate])
Broadcast a set of related MuxObjUpdates from ONE atomic backend
transition as ONE waveobj:batchedupdates WS frame, so the frontend
applies them in a single reactive flush (updateMuxObjects’s
batch()), preserving the array’s order.
Why one frame instead of N waveobj:update frames: each frame is
dispatched (and painted) independently by the renderer, so a
[delete tab, update workspace] pair sent as two frames blanks the
still-mounted tab a full paint before the workspace update unmounts
it — the same flash class
SPEC_TAB_CLOSE_BUTTON_SELECT_FLASH_2026_08_25.md §6 fixed at the
RPC-response layer, riding in unbatched through the WS push path
instead (§7). Single-update callers (blockcontroller, setmeta, the
wave-obj bridge) keep emitting plain waveobj:update — there is
nothing to batch there.
Sourcepub fn broadcast_event_lane(&self, event: &WSEventType, lane: Lane)
pub fn broadcast_event_lane(&self, event: &WSEventType, lane: Lane)
Broadcast an event to all connected WebSocket clients on a specific lane.
Sourcepub fn broadcast_value_lane(&self, data: Value, lane: Lane)
pub fn broadcast_value_lane(&self, data: Value, lane: Lane)
Self::broadcast_event_lane for an already-built wire Value.
Sourcefn try_send_lane(conn_id: &str, sender: &Sender<Value>, data: Value)
fn try_send_lane(conn_id: &str, sender: &Sender<Value>, data: Value)
Non-blocking send with distinct logging for a genuinely-full lane
(stalled/hidden-renderer consumer — see PRIORITY_LANE_CAPACITY /
BACKGROUND_LANE_CAPACITY) vs. a closed one (connection already
gone). Never blocks the caller — callers hold the watches lock.
Sourcepub fn send_to_tab(&self, tab_id: &str, event: &WSEventType)
pub fn send_to_tab(&self, tab_id: &str, event: &WSEventType)
Send an event to connections matching a specific tab_id.
Sourcepub fn connection_count(&self) -> usize
pub fn connection_count(&self) -> usize
Get the number of active connections.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for EventBus
impl RefUnwindSafe for EventBus
impl Send for EventBus
impl Sync for EventBus
impl Unpin for EventBus
impl UnsafeUnpin for EventBus
impl UnwindSafe for EventBus
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<T> DowncastSync for T
impl<T> DowncastSync for T
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