Realtime Client

Deprecated
View as MarkdownOpen in Claude
Deprecated

It’s no longer needed to create the client manually. You can use the product constructors, like Video.Client, to access the same functionality.

A real-time Client. To construct an instance of this class, please use createClient.

Example usage:

1import { createClient } from "@signalwire/realtime-api";
2
3// Obtain a client:
4const client = await createClient({ project, token });
5
6// Listen on events:
7client.video.on("room.started", async (room) => {});
8
9// Connect:
10await client.connect();

Properties

Methods

connect

  • connect(): Promise<RealtimeClient>

Connects this client to the SignalWire network.

As a general best practice, it is suggested to connect the event listeners before connecting the client, so that no events are lost.

Returns

Promise<RealtimeClient>

Upon connection, asynchronously returns an instance of this same object.

Example

1const client = await createClient({ project, token });
2client.video.on("room.started", async (roomSession) => {}); // connect events
3await client.connect();

disconnect

  • disconnect(): void

Disconnects this client from the SignalWire network.

Returns

void


off

  • off(event, fn?)

Remove an event handler.

Parameters

NameTypeDescription
eventstringName of the event.
fn?FunctionAn event handler which had been previously attached.

on

  • on(event, fn)

Attaches an event handler to the specified event.

Parameters

NameTypeDescription
eventstringName of the event.
fnFunctionAn event handler.

once

  • once(event, fn)

Attaches an event handler to the specified event. The handler will fire only once.

Parameters

NameTypeDescription
eventstringName of the event.
fnFunctionAn event handler.

removeAllListeners

  • removeAllListeners(event?)

Detaches all event listeners for the specified event.

Parameters

NameTypeDescription
event?stringName of the event (leave this undefined to detach listeners for all events).