Class MockRTCServerPeer

A MockRTC peer represents a target you can connect to, and exposes an API to create offers or answers to create new connections.

Peers have defined behaviour, and each connection will be handled accordingly and independently.

Peers can also optionally track all the messages and metadata across all their connections.

Hierarchy

  • MockRTCServerPeer

Implements

Constructors

Properties

peerId: string = ...

Methods

  • 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

    • offer: RTCSessionDescriptionInit
    • Optional options: AnswerOptions

    Returns Promise<MockRTCExternalAnswerParams>

  • 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 on a specific channel that this peer has received on all connections.

    Parameters

    • channelName: string

    Returns Promise<(string | Buffer)[]>

Generated using TypeDoc