Skip to main content

EventBus

Struct EventBus 

Source
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

Source

pub fn new() -> Self

Source

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.

Source

pub fn unregister_ws(&self, conn_id: &str)

Unregister a WebSocket connection.

Source

pub fn has_connections_for(&self, tab_id: &str) -> bool

Check if any connections exist for a given window/tab ID.

Source

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).

Source

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.

Source

pub fn broadcast_event(&self, event: &WSEventType)

Broadcast an event to all connected WebSocket clients, on the priority lane.

Source

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.

Source

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.

Source

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).

Source

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.

Source

pub fn broadcast_event_lane(&self, event: &WSEventType, lane: Lane)

Broadcast an event to all connected WebSocket clients on a specific lane.

Source

pub fn broadcast_value_lane(&self, data: Value, lane: Lane)

Self::broadcast_event_lane for an already-built wire Value.

Source

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.

Source

pub fn send_to_tab(&self, tab_id: &str, event: &WSEventType)

Send an event to connections matching a specific tab_id.

Source

pub fn connection_count(&self) -> usize

Get the number of active connections.

Trait Implementations§

Source§

impl Default for EventBus

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &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
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> NoneValue for T
where T: Default,

§

type NoneType = T

§

fn null_value() -> T

The none-equivalent value.
§

impl<T> NoneValue for T
where T: Default,

§

type NoneType = T

§

fn null_value() -> T

The none-equivalent value.
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more