rtcpool.pool

class Pool(base_config, signaller)

A pool of WebRTC connections. All negotiations are handled internally, and while RTCPeerConnections can be directly accessed by connection ID, this class has sufficient functionality to manage media and data channels without directly interacting with them.

Create an RTC pool from a TURN/STUN config and a signaller.

Arguments
Pool.connections

type: array

A list of every ManagedConnection().

Pool.events

type: EventTarget

The interface for all events triggered by connections. The events which are exposed and dispatched to this EventTarget are ‘join’, ‘close’, and ‘describe.’

Pool.id

type: string

The ID of this endpoint. Will be null if no pool has been joined successfully.

Pool.nconnections

type: number

The number of connections open.

Pool.close(evt_type)

Closes all connections, as well as the signalling channel. Causes a ‘close’ event to be dispatched to {this.events}

Pool.getConnection(id)

Gets the RTCPeerConnection associated with the specified endpoint.

Arguments
  • id (string()) – The ID of the endpoint connection to get.

Returns

ManagedConnection|null – The ManagedConnection() to the desired endpoint, or null if it does not exist.

Pool.join(pool)

Sends a ‘join’ message to the signalling server to join a pool. This method will not throw an exception, but if this endpoint is already part of one, the signalling server will return an error.

Arguments
  • pool (string()) – The ID of the pool to join.