@not3/sdk
    Preparing search index...

    Class P2PSignaling

    A thin typed client for the API's /p2p signaling gateway.

    The WebSocket constructor is injected so this works in browsers and in Node without pulling in a runtime dependency.

    Index

    Constructors

    • Create a signaling client.

      Parameters

      • url: string

        The gateway URL.

      • webSocketCtor: {
            CLOSED: 3;
            CLOSING: 2;
            CONNECTING: 0;
            OPEN: 1;
            prototype: WebSocket;
            new (url: string | URL, protocols?: string | string[]): WebSocket;
        }

        The WebSocket implementation to use.

      Returns P2PSignaling

    Properties

    onClose: ((err?: Error) => void) | null = null

    Called when the socket drops or the server reports an unsolicited error.

    onPeerJoined: (() => void) | null = null

    Called when a receiver joins the session.

    onPeerLeft: (() => void) | null = null

    Called when the peer leaves the session.

    onSignal: ((payload: unknown) => void) | null = null

    Called for every relayed signal payload from the peer.

    Methods

    • Open the socket.

      Returns Promise<void>

      A promise that resolves once the socket is open.

    • Relay an opaque WebRTC signaling payload to the peer.

      Parameters

      • payload: unknown

        The payload to relay.

      Returns void

      Error If the socket is not open.