peerix - v0.5.0
    Preparing search index...

    Class CentrifugeDriver

    Centrifuge-based signaling driver.

    This driver uses Centrifugo as the underlying messaging system, allowing signaling messages to be exchanged through a Centrifuge-based server.

    This driver requires the centrifuge module in the browser.

    import { Centrifuge } from "centrifuge";

    // connect to a Centrifuge server
    const centrifuge = new Centrifuge("ws://localhost:8000/connection/websocket");
    centrifuge.connect();

    // create a new driver instance
    const driver = new CentrifugeDriver({ centrifuge });

    Running a Centrifugo server locally for testing:

    docker run --rm --ulimit nofile=65536:65536 -p 8000:8000 \
    -e CENTRIFUGO_CLIENT_ALLOWED_ORIGINS="*" \
    -e CENTRIFUGO_CLIENT_INSECURE=true \
    centrifugo/centrifugo centrifugo

    Hierarchy (View Summary)

    Index

    Constructors

    • Creates a new instance of the driver.

      Parameters

      • options: { centrifuge: CentrifugeClient; prefix?: string }

        Optional configuration for the driver.

        • centrifuge: CentrifugeClient

          The Centrifuge client instance.

        • Optionalprefix?: string

          Optional prefix for Centrifuge channels.

      Returns CentrifugeDriver

    Accessors

    • get active(): boolean

      Indicates whether the driver is currently active.

      Returns boolean

    • set active(value: boolean): void

      Sets the active state of the driver and emits corresponding events.

      Parameters

      • value: boolean

      Returns void

    Methods

    • Publishes a signaling message to the specified namespace.

      Parameters

      • namespace: string[]

        The namespace to publish the message to.

      • data: number[]

        The message data to publish.

      Returns Promise<void>

    • Subscribes to signaling messages for the specified namespace.

      Parameters

      • namespace: string[]

        The namespace to subscribe to.

      • handler: (data: number[]) => void

        The handler function to call when a message is received.

      Returns Promise<void>

    • Unsubscribes from signaling messages for the specified namespace.

      Parameters

      • namespace: string[]

        The namespace to unsubscribe from.

      • handler: (data: number[]) => void

        The handler function to remove.

      Returns Promise<void>