Class MockRTCHandlerBuilder<R>

The builder logic for composing RTC handling behaviour for both mock peers and rules, by internally queuing defined actions until a .thenX() method is called to compile the actions into either a peer or a rule (handled by an constructor callback param).

Type Parameters

  • R

Hierarchy

Steps

  • Send a message or buffer on the connection's data channels.

    This can take one or two arguments. If only one is provided, it is used as a message that's sent on all open data channels. If two arguments are provided, the first must be the data channel label, and the message (the second) will be sent only to data channel(s) with that label.

    If no matching channels are open, this is a no-op. Use waitForChannel() to ensure the channels you're expecting are open first if necessary.

    Parameters

    • message: string | Buffer

    Returns MockRTCHandlerBuilder<R>

  • Parameters

    • channel: undefined | string
    • message: string | Buffer

    Returns MockRTCHandlerBuilder<R>

Final Steps

  • Immediately close the connection.

    This defines a final step, and will then create a mock peer from the full set of steps you've defined, and return it wrapped in a promise. As soon as the promise resolves the peer is ready to use.

    Returns Promise<R>

  • Echo all incoming data channel messages until the other peer closes the connection.

    This defines a final step, and will then create a mock peer from the full set of steps you've defined, and return it wrapped in a promise. As soon as the promise resolves the peer is ready to use.

    Returns Promise<R>

  • Creates a new external connection to the given remote peer connection, matching the existing mocked connection, and then proxies all traffic through to that peer.

    This defines a final step, and will then create a mock peer from the full set of steps you've defined, and return it wrapped in a promise. As soon as the promise resolves the peer is ready to use.

    Parameters

    • peer: RTCPeerConnection

    Returns Promise<R>

  • Proxy this connection dynamically to the 'real' target peer, whoever that may be.

    This assumes that you have an existing external connection already set up and attached to this mock connection.

    You can do that either by using hookWebRTCConnection or hookAllWebRTC to hook your connection during normal setup to automatically create an external offer to the real remote peer, or you can do so manually using createExternalOffer or answerExternalOffer and then passing the connection id as here.

    This defines a final step, and will then create a mock peer from the full set of steps you've defined, and return it wrapped in a promise. As soon as the promise resolves the peer is ready to use.

    Returns Promise<R>

  • Send a message or buffer on the connection's data channels, then close the connection. This is equivalent to .send() then .thenClose().

    This defines a final step, and will then create a mock peer from the full set of steps you've defined, and return it wrapped in a promise. As soon as the promise resolves the peer is ready to use.

    Parameters

    • message: string | Buffer

    Returns Promise<R>

  • Parameters

    • channel: string
    • message: string | Buffer

    Returns Promise<R>

Other

Generated using TypeDoc