RTCForge API Reference v1.1.1
    Preparing search index...

    Class LocalMessageBus

    In-process MessageBus that delivers messages synchronously to local subscribers.

    Suitable for single-process deployments and tests; messages are not propagated across processes or hosts. During publish the subscriber set is snapshotted, so handlers may subscribe or unsubscribe without disturbing the current delivery. Although the method is async, delivery to handlers happens synchronously before the returned promise resolves.

    const bus = new LocalMessageBus()
    const off = bus.subscribe('room:1', (msg) => console.log(msg))
    await bus.publish('room:1', { type: 'joined', peer: 'p1' })
    off() // stop receiving

    Implements

    Index

    Constructors

    Methods

    Constructors

    • Parameters

      • OptionalonError: (err: unknown, topic: string) => void

        Invoked when a subscriber throws. Delivery continues to the remaining subscribers regardless. Defaults to console.error.

      Returns LocalMessageBus

    Methods

    • Publishes message to all current subscribers of topic.

      Parameters

      • topic: string

        The topic to publish on.

      • message: unknown

        The payload to deliver to subscribers.

      Returns Promise<void>