Start creating a mock WebRTC peer. This method returns a builder, who
must be configured with the mock peer's settings. Once configured the
peer can be created by calling any .thenX()
method to define the
peer's behaviour.
This API allows you to define a single set of handling steps, and then connect directly to the resulting peer to run those steps directly.
To instead define multiple behaviours that match different conditions, and
then connect clients who may each see different behaviour, define your
rules using the forX()
methods, and connect by using getMatchingPeer()
.
Create a peer from a set of step definitions.
This API is only useful if you're building peers from data programmatically,
rather than using buildPeer()
and MockRTCPeerBuilder
, which are generally
preferable otherwise.
Starting defining a mock WebRTC rule. This methods returns a rule builder,
which can be configured to define which incoming connections should be
matched, with methods like .fromPageHostname(hostname)
.
Once the matching is configured, start calling handler methods like
.send()
to define a series of steps to run for matching connections,
and then call a .thenX()
method to complete the definition and
define the rule.
The rule definition is not complete until the returned promise resolves.
Once it has resolved successfully, any future connections to the peer
returned by getMatchingPeer()
will be matched against these rules,
and will run the steps for the first matching rule found.
Get the rule-matching peer.
This peer accepts connections, matches them against defined rules (defined
via the .forX()
methods) and then handles them according to the steps
for the defined rule.
To more directly define a set of steps and make a connection that will
follow those steps, define a peer with .buildPeer()
and then connect
to that directly.
The default behaviour of this peer for unmatched connections is equivalent
to .thenPassThrough()
- it will accept all incoming data without response
initially, and proxy all data to a remote peer if one is attached.
Subscribe to events to monitor WebRTC interactions across all peers managed by this MockRTC session. The events available include:
peer-connected
peer-disconnected
external-peer-attached
data-channel-opened
data-channel-message-sent
data-channel-message-received
data-channel-closed
media-track-opened
media-track-stats
media-track-closed
Create a connection-matching rule from a set of matchers and step definitions.
This API is only useful if you're building rule from data programmatically,
rather than using forX()
and MockRTCHandlerBuilder
, which are generally
preferable otherwise.
Generated using TypeDoc
Create a connection-matching rule from a set of matchers and step definitions.
This API is only useful if you're building rule from data programmatically, rather than using
forX()
andMockRTCHandlerBuilder
, which are generally preferable otherwise.