MockRTC API Reference
    Preparing search index...

    Interface MockRTCServerPeer

    interface MockRTCServerPeer {
        peerId: string;
        answerExternalOffer(
            offer: RTCSessionDescriptionInit,
            options?: AnswerOptions,
        ): Promise<MockRTCExternalAnswerParams>;
        answerOffer(
            offer: RTCSessionDescriptionInit,
            options?: AnswerOptions,
        ): Promise<MockRTCAnswerParams>;
        close(): Promise<void>;
        createExternalOffer(
            options?: OfferOptions,
        ): Promise<MockRTCExternalOfferParams>;
        createOffer(options?: OfferOptions): Promise<MockRTCOfferParams>;
        getAllMessages(): Promise<(string | Buffer<ArrayBufferLike>)[]>;
        getMessagesOnChannel(
            channelName: string,
        ): Promise<(string | Buffer<ArrayBufferLike>)[]>;
        getSession(id: string): MockRTCSession;
    }

    Implements

    Index
    peerId: string = ...
    • Takes an offer for a WebRTC connection elsewhere, and creates an answer to create an external connection to this peer.

      External connections are used for proxying traffic. They do not do anything by default (so they ignore this peer's configured steps) but a mock connection can be connected to an external connection using methods like thenPassThrough.

      Returns a set of answer parameters: an external connection id, the answer itself, and a session to renegotiate the connection in future.

      Parameters

      Returns Promise<MockRTCExternalAnswerParams>

    • Takes an offer for a WebRTC connection elsewhere, and creates an answer to connect that to this peer.

      Returns a set of answer parameters: the answer itself, and a session to renegotiate the connection in future.

      Parameters

      Returns Promise<MockRTCAnswerParams>

    • Creates an offer for a new external connection to this mock peer.

      External connections are used for proxying traffic. They do not do anything by default (so they ignore this peer's configured steps) but a mock connection can be connected to an external connection using methods like thenPassThrough.

      Returns a set of offer parameters: an external connection id, the offer itself, a session to renegotiate the connection in future, and a setAnswer callback to call with an answer once you have one.

      Parameters

      Returns Promise<MockRTCExternalOfferParams>

    • Retrieve an array of all data channel messages that this peer has received on all connections.

      Returns Promise<(string | Buffer<ArrayBufferLike>)[]>

    • Retrieve an array of all data channel messages on a specific channel that this peer has received on all connections.

      Parameters

      • channelName: string

      Returns Promise<(string | Buffer<ArrayBufferLike>)[]>

    • Takes a connection id, and returns the associated session.

      This is useful for advanced use cases, where keeping the session returned by other setup methods is inconvenient, and it's easier to keep ids and look up sessions on demand instead.

      Parameters

      • id: string

      Returns MockRTCSession