Wraps an open WebSocket as a peer and begins listening for inbound
messages and the socket close event.
Peer configuration; see PeerOptions.
ReadonlyidStable identifier for this peer.
ReadonlymetadataImmutable (frozen) copy of the metadata supplied at join time.
Epoch-millisecond timestamp of the peer's most recent heartbeat pong (initialized to construction time). Used by the heartbeat monitor to prune unresponsive peers.
The peer's current role. Empty string if none was assigned.
Marks the peer as admitted to its room.
Called by SignalingServer only after the peer has been successfully
added to a Room. Until then, inbound signal and broadcast
frames are ignored so an un-admitted (or about-to-be-rejected) peer cannot
relay or broadcast during the async admission window.
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).
Reports whether the peer has ponged recently enough to be considered live.
Cutoff timestamp in epoch milliseconds; the peer is alive if its last pong is at or after this value.
true if the peer is still considered connected.
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 PeerEventsThe event name to clear; if omitted, listeners for every event are removed.
This emitter, for chaining.
Serializes and sends a message to the peer over its WebSocket.
The server message to send.
OptionaliceServers?: { credential?: string; urls: string | string[]; username?: string }[]OptionallocalRole?: stringOptionalpeerMetadata?: Record<string, Record<string, string>>OptionalpeerRoles?: Record<string, string>Optionalv?: numberServer's signaling protocol version; see PROTOCOL_VERSION. Optional for back-compat.
If the WebSocket is not open, or if the underlying send fails (which also emits PeerEvent.Error).
Sets the peer's role.
The new role string.
Updates local state only; use Room.setPeerRole to also notify the rest of the room.
A single connected client within a Room.
Remarks
Wraps the underlying WebSocket: it parses and validates inbound ClientMessages, applies optional per-peer rate limiting, tracks the last heartbeat pong for liveness, and serializes outbound ServerMessages. It extends the core
EventEmitterand emits PeerEvent values (signal,broadcast,pong,error,rate-limit-exceeded,disconnected). Peers are created and owned by SignalingServer; you usually obtain them via Room.getPeers.