Creates an instance of Peer.
Optionaloptions: PeerOptionsPeer configuration options.
ReadonlyaddonsAttachable extensions.
ReadonlychannelsConfigured local data channels indexed by channel id.
ReadonlyconnectionsActive remote peers indexed by remote peer id.
ReadonlyconnectionMaximum time in seconds to wait for ICE connection establishment.
ReadonlydriverSignaling transport used to exchange SDP and ICE messages.
ReadonlyiceSTUN/TURN servers passed to every RTCPeerConnection instance.
ReadonlyiceICE transport policy for created peer connections.
ReadonlyidUnique identifier of the local peer.
Optional metadata announced to other peers in signaling messages.
Current room name. Empty until join() is called.
ReadonlystreamsPublished local streams indexed by application-level stream id.
Indicates whether the peer is currently active.
True if the Peer is joined to a room, false otherwise.
Attach an addon/extension to the peer instance.
Addon instance to attach.
Close and unregister a negotiated data channel by id.
Channel id or object containing id.
Detach a previously attached addon/extension from the peer instance.
Addon instance to detach.
Emit one or more events.
Event name or list of event names.
Event payload.
Join a room and start listening for incoming connections.
Optionaloptions: string | JoinOptionsRoom name or join options.
Leave the current room and close all active remote connections.
Remove a previously registered event listener.
Event name or list of event names.
Optionalhandler: (...args: PeerEvents[K]) => voidEvent handler to remove. If omitted, all handlers for the given event(s) will be removed.
Subscribe to one or more peer events.
Event name or list of event names.
Event handler.
Subscribe to an event and auto-unsubscribe after first invocation.
Event name or list of event names.
Event handler.
Register or create a negotiated data channel with all remote peers.
Channel options or channel id.
Publish or update a local media stream.
When already active, this updates senders on every current connection and triggers negotiation where applicable.
Stream descriptor or MediaStream instance.
Send a message through data channels.
If options is omitted, the message is sent to all open channels for every
connected remote peer. If options is a number, it is treated as channel id.
Message payload to send. This may be a string, a Blob, an ArrayBuffer, a TypedArray or a DataView object.
Optionaloptions: number | SendOptionsOptional send options or channel id.
Stop publishing a previously published local stream.
Stream identifier or object containing id.
Peer class for managing WebRTC peer connections and signaling.
Example