Interface MockRTCPeerBuilder

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).

interface MockRTCPeerBuilder {
    createDataChannel(channelLabel: string): MockRTCHandlerBuilder<MockRTCPeer>;
    send(message: string | Buffer): MockRTCHandlerBuilder<MockRTCPeer>;
    send(channel: undefined | string, message: string | Buffer): MockRTCHandlerBuilder<MockRTCPeer>;
    sleep(duration: number): MockRTCHandlerBuilder<MockRTCPeer>;
    thenClose(): Promise<MockRTCPeer>;
    thenEcho(): Promise<MockRTCPeer>;
    thenForwardTo(peer: RTCPeerConnection): Promise<MockRTCPeer>;
    thenPassThrough(): Promise<MockRTCPeer>;
    thenSend(message: string | Buffer): Promise<MockRTCPeer>;
    thenSend(channel: string, message: string | Buffer): Promise<MockRTCPeer>;
    waitForChannel(channelLabel?: string): MockRTCHandlerBuilder<MockRTCPeer>;
    waitForNextMedia(): MockRTCHandlerBuilder<MockRTCPeer>;
    waitForNextMessage(): MockRTCHandlerBuilder<MockRTCPeer>;
    waitForNextMessageOnChannel(channelLabel: string): MockRTCHandlerBuilder<MockRTCPeer>;
    waitForTrack(): MockRTCHandlerBuilder<MockRTCPeer>;
}

Hierarchy (view full)

Steps

Final Steps

  • 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<MockRTCPeer>

  • 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<MockRTCPeer>