peerix - v0.8.0
    Preparing search index...

    Interface RoomOptions<M>

    Configuration options for creating a Room instance.

    interface RoomOptions<M extends object = Metadata> {
        connectionTimeout?: number;
        driver?: Driver;
        iceCandidateDebounce?: number;
        iceServers?: IceServer[];
        iceTransportPolicy?: IceTransportPolicy;
        id?: string;
        namespaceHashing?: boolean;
        signalingCompression?: boolean;
        signalingEncryption?: boolean;
        verify?: (options: PeerInfo<M>) => boolean | Promise<boolean>;
        webrtc?: WebRTCImplementation;
    }

    Type Parameters

    Index
    connectionTimeout?: number

    Connection timeout in milliseconds. By default, it is set to 15000 ms (15 seconds). Use 0 to disable the timeout.

    driver?: Driver

    Signaling driver instance for message exchange between peers. If omitted, a default in-memory driver is used, which is suitable for testing purposes only.

    iceCandidateDebounce?: number

    Debounce time in milliseconds for batching ICE candidates before sending them through signaling to minimize the number of messages. By default, it is set to 50 ms.

    iceServers?: IceServer[]

    An array of objects, each describing one server which may be used by the ICE agent; these are typically STUN and/or TURN servers. If this isn't specified, the connection attempt will be made with no STUN or TURN server available, which limits the connection to local peers. Empty by default.

    iceServers: [{
    urls: "stun:stun.l.google.com:19302"
    }]
    iceTransportPolicy?: IceTransportPolicy

    ICE policy used by created RTCPeerConnection instances. If set to "relay", only relay candidates will be used, otherwise all candidates will be considered.

    id?: string

    Unique identifier for the room. Uses "default" if omitted.

    namespaceHashing?: boolean

    Enable hashing of namespaces in signaling messages for privacy. Enabled by default.

    signalingCompression?: boolean

    Enable compression for signaling messages to reduce bandwidth usage by about 40%. A message is compressed only for a peer that has shown it can decompress, so the first messages to a peer may be uncompressed. Enabled by default.

    signalingEncryption?: boolean

    Encrypt signaling messages between peers with AES-GCM, using keys derived with ECDH from each peer's ID, which is its public key. This hides the messages, including peer metadata and SDP, from the signaling backend and other observers. Peer IDs are not authenticated, so it does not protect against a backend that actively impersonates peers. Enabled by default.

    verify?: (options: PeerInfo<M>) => boolean | Promise<boolean>

    Optional callback to accept or reject incoming peer connections. It may be called more than once for the same peer.

    Type Declaration

      • (options: PeerInfo<M>): boolean | Promise<boolean>
      • Parameters

        • options: PeerInfo<M>

          Options describing the incoming peer connection.

          Peer identifier and the metadata it joined with.

          Metadata of remote peers comes from the network and is not validated, so check it in the room's verify callback before relying on its type.

          • id: string

            Peer identifier.

          • Optionalmetadata?: M

            Metadata the peer joined with.

        Returns boolean | Promise<boolean>

        A boolean or promise indicating whether the incoming connection should be accepted.

    WebRTC classes to use instead of the globals, for runtimes such as Node.js that do not provide them. Each class falls back to its global.

    // npm install @roamhq/wrtc
    import { RTCPeerConnection, MediaStream } from "@roamhq/wrtc";

    const room = new Room({ driver, webrtc: { RTCPeerConnection, MediaStream } });