Whether this side is the "polite" peer. On an offer collision the polite peer rolls back its local offer and accepts the remote one, while the impolite peer ignores the remote offer.
Connection options (ICE servers, codec preference, simulcast,
candidate filter, peer connection factory). Defaults to {}.
Adds a remote ICE candidate. If the remote description is not yet set, the
candidate is buffered (up to an internal cap) and applied once it is;
a null candidate signals end-of-candidates.
The remote ICE candidate, or null for end-of-candidates.
Emits ConnectionEvent.Error if the pending-candidate buffer overflows.
Adds a local track to the connection, triggering renegotiation. When
simulcast layers or a maxBitrate are configured, a transceiver with the
corresponding send encodings is created; otherwise a plain sender is added.
Any configured codec preference is then applied.
The local media track to send.
The stream the track belongs to.
OptionalmaxBitrate: numberOptional maximum send bitrate, in bits per second (ignored when simulcast layers are configured).
The RTCRtpSender for the added track.
Closes the underlying RTCPeerConnection and releases its resources.
Creates a locally initiated RTCDataChannel on this connection.
Channel label.
Optionalopts: RTCDataChannelInitOptional data channel configuration (ordering, reliability).
The created data channel.
Synchronously invokes every listener registered for event, in registration order.
true if at least one listener was invoked, false if there were none.
The listener list is snapshotted before dispatch, so mutations made by handlers take effect only on subsequent emissions. Listeners are isolated: if one throws, the remaining listeners still run and the error is surfaced via console.error rather than swallowed silently (consistent with LocalMessageBus).
Retrieves connection statistics.
The RTCStatsReport for this connection.
Applies a remote SDP answer to a previously sent offer, then flushes any buffered ICE candidates. Emits ConnectionEvent.Error on failure.
The remote answer SDP.
Applies a remote SDP offer and produces an answer, handling offer collisions per the perfect-negotiation algorithm.
The remote offer SDP.
The local answer description to send back, or null if the offer
was ignored (impolite peer during a collision) or an error occurred (an
ConnectionEvent.Error is emitted in the error case).
Returns the number of listeners currently registered for event.
The event name to count listeners for.
The count of registered listeners (0 if none).
Registers a listener that is invoked at most once: it is removed automatically before
being called the first time event is emitted.
This emitter, for chaining.
Remove a pending one-time listener by passing the same function reference to off.
Removes listeners for a single event, or for all events.
Optionalevent: keyof PeerConnectionEventsThe event name to clear; if omitted, listeners for every event are removed.
This emitter, for chaining.
Removes a previously added local track and its sender, triggering renegotiation. No-op if the track was not added to this connection.
The local track to remove.
Swaps the track on an existing sender in place, without renegotiation
(e.g. switching camera device or camera-to-screen). No-op if oldTrack
was not added to this connection.
The currently sent track.
The track to send in its place.
Restarts ICE, forcing a fresh connectivity check. Useful after a network change to recover a connection.
Browser P2P wrapper around a single
RTCPeerConnection, implementing the "perfect negotiation" pattern: it debouncesnegotiationneeded, resolves offer collisions using thepoliterole, and buffers ICE candidates that arrive before the remote description is set. It emits ConnectionEvents rather than exposing the raw connection.Remarks
This is the per-peer building block driven by Call; applications typically use Call instead of constructing this directly.