You can use the realtime SDK to listen for and react to events from SignalWire's RealTime APIs.

To get started, create a realtime client with createClient and listen for events. For example:

const { createClient } = require('@signalwire/realtime-api')

createClient({
  project: '<project-id>',
  token: '<project-token>'
}).then((client) => {
  client.video.on('room.started', async (roomSession) => {
    console.log("Room started")
  
    roomSession.on('member.joined', async (member) => {
      console.log(member)
    })
  
    await roomSession.subscribe()
  });

  client.connect()
});

Namespaces

Interfaces

Functions

createClient

Const createClient(userOptions): Promise<RealtimeClient>

Creates a real-time Client.

Parameters

NameTypeDescription
userOptionsObject
userOptions.logLevel?"error" | "trace" | "debug" | "info" | "warn" | "silent"

logging level

userOptions.project?string

SignalWire project id, e.g. a10d8a9f-2166-4e82-56ff-118bc3a4840f

userOptions.tokenstring

SignalWire project token, e.g. PT9e5660c101cd140a1c93a0197640a369cf5f16975a0079c9

Returns

Promise<RealtimeClient>

an instance of a real-time Client.

Example

const client = await createClient({
  project: '<project-id>',
  token: '<project-token>'
})