@not3/sdk
    Preparing search index...

    Class P2PRoom

    An encrypted WebRTC mesh room. The gateway handles membership and directed signaling; application framing and document state belong to the caller.

    Index

    Constructors

    Properties

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

    Called once when the room closes. A signaling loss with live peer channels instead calls opts.onSignalingLost; those channels keep working until leave() or the last peer disconnects.

    onMessage: ((peerId: string, data: string | ArrayBuffer) => void) | null = null

    Called for a decrypted string or binary message.

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

    Called when a peer's data channel opens.

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

    Called when a peer's data channel closes or fails authentication.

    onStateChange: ((state: P2PRoomState) => void) | null = null

    Called on each room state change.

    Accessors

    • get peerId(): string | null

      This member's gateway id after a successful create or join.

      Returns string | null

    Methods

    • Send one encrypted message to every currently connected peer.

      Parameters

      • data: string | ArrayBuffer | Uint8Array<ArrayBufferLike>

      Returns Promise<void>

    • Create a new room and resolve on the gateway grant.

      Returns Promise<{ peerId: string; roomId: string }>

    • Join an existing room; data channels may open after this resolves.

      Parameters

      • roomId: string

      Returns Promise<{ peerId: string; peers: string[] }>

    • Leave the room and close all peer channels. Calls onClose once.

      Returns void

    • Send one encrypted message to a connected peer.

      Parameters

      • peerId: string
      • data: string | ArrayBuffer | Uint8Array<ArrayBufferLike>

      Returns Promise<void>