Interface MockRTCPeer

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

  • MockRTCPeer

Implemented by

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>

  • 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

    • offer: RTCSessionDescriptionInit
    • Optional options: AnswerOptions

    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>

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

    Returns a set of offer parameters: 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<MockRTCOfferParams>

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

    Returns Promise<(string | Buffer)[]>

  • 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)[]>

  • 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

Generated using TypeDoc