Skip to main content
Version: v1.41.0

RealTimeConnection

A shared connection that multiple Stage instances can use to communicate with the IVS real-time service over a single physical network transport.

Construct it with a connection token, pass it to one or more Stages via StageConfiguration, and call join() on any of those stages — the connection auto-connects on the first join. Call connect() explicitly to establish the transport in advance (reduces time-to-video for later joins). The connection must outlive every Stage created with it.

Extends​

Constructors​

new RealTimeConnection()​

new RealTimeConnection(connectionToken): RealTimeConnection

Creates a connection from a connection token. Throws RealTimeConnectionError synchronously when the token is malformed (1053) or expired (1054).

Parameters​

ParameterTypeDescription
connectionTokenstringaccount-scoped connection token (JWT)

Returns​

RealTimeConnection

Overrides​

TypedEmitter<RealTimeConnectionEventMap>.constructor

Methods​

connect()​

connect(): void

Opens the connection. The first Stage join also opens it automatically.

Returns​

void

Throws​

If the token has expired or connection setup fails


disconnect()​

disconnect(): void

Closes the connection, leaves every Stage using it, and remains reusable.

Returns​

void


hasListenersFor()​

hasListenersFor<Event>(event): boolean

Returns a boolean indicating whether an event has actively registered listeners.

Type Parameters​

Type Parameter
Event extends "stateChanged"

Parameters​

ParameterTypeDescription
eventEventthe event to register the callback for

Returns​

boolean

Inherited from​

TypedEmitter.hasListenersFor


off()​

off<Event>(event, callback, context?): void

Deregister a new callback based on the event provided. The events enum is either linked in the EventMap type or in the root of the class.

Type Parameters​

Type Parameter
Event extends "stateChanged"

Parameters​

ParameterTypeDescription
eventEventthe event to de-register the callback for
callbackRealTimeConnectionEventMap[Event]the callback to be de-registered
context?any-

Returns​

void

Inherited from​

TypedEmitter.off


on()​

on<Event>(event, callback, context?): void

Register a new callback based on the event provided. The events enum is either linked in the EventMap type or in the root of the class.

Type Parameters​

Type Parameter
Event extends "stateChanged"

Parameters​

ParameterTypeDescription
eventEventthe event to register the callback for
callbackRealTimeConnectionEventMap[Event]the callback to be invoked for the event
context?any-

Returns​

void

Inherited from​

TypedEmitter.on