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
TypedEmitter<RealTimeConnectionEventMap>
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
| Parameter | Type | Description |
|---|---|---|
connectionToken | string | account-scoped connection token (JWT) |
Returns
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
| Parameter | Type | Description |
|---|---|---|
event | Event | the 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
| Parameter | Type | Description |
|---|---|---|
event | Event | the event to de-register the callback for |
callback | RealTimeConnectionEventMap[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
| Parameter | Type | Description |
|---|---|---|
event | Event | the event to register the callback for |
callback | RealTimeConnectionEventMap[Event] | the callback to be invoked for the event |
context? | any | - |
Returns
void
Inherited from
TypedEmitter.on