@sovereignbase/actor-channel
    Preparing search index...

    Class ActorChannel<Topic, Message, RPCRequest, RPCResponse>

    Coordinates RPC requests and topic messages across the current browsing context, other same-origin browsing contexts, and connected brokers.

    Type Parameters

    • Topic extends string

      The topic identifier type.

    • Message

      The published message type.

    • RPCRequest

      The RPC request payload type.

    • RPCResponse

      The RPC response payload type.

    Index
    • get rpcAvailable(): boolean

      Whether at least one RPC-enabled broker is currently available.

      Returns boolean

    • Maintains a best-effort connection to a broker while this channel owns the broker URL's Web Lock.

      Parameters

      • brokerUrl: string

        The broker WebSocket URL.

      • rpcEnabled: boolean = false

        Whether the connection may carry RPC requests.

      Returns Promise<void>

      A promise that settles when connection maintenance stops.

    • Publishes a message to the local swarm and subscribed broker peers.

      Parameters

      • topic: Topic

        The topic to publish to.

      • detail: Message

        The message payload.

      Returns void

    • Sends an RPC request to an available RPC-enabled broker.

      The request is not queued when no RPC-enabled broker is available.

      Parameters

      Returns string

      The identifier assigned to the request.

    • Subscribes this browsing context to a topic.

      Repeated subscriptions to the same topic have no effect.

      Parameters

      • topic: Topic

        The topic to subscribe to.

      Returns void

    • Removes this browsing context's subscription to a topic.

      Parameters

      • topic: Topic

        The topic to unsubscribe from.

      Returns void