Skip to main content

RoomSession

Represents a room session. You can obtain instances of this class by subscribing to the appropriate events from Video.Client.

Example

import { SignalWire } from "@signalwire/realtime-api";

const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" })

const videoClient = client.video;

await videoClient.listen({
onRoomStarted: (roomsession) => {
console.log(roomsession);
}
})

Properties

displayName

displayName: string

Display name for this room. Defaults to the value of name.


hideVideoMuted

hideVideoMuted: boolean

Whether muted videos are shown in the room layout. See setHideVideoMuted.


id

id: string

Unique id for this room session.


layoutName

layoutName: string

Current layout name used in the room.


meta

meta: Record<record-type><string, unknown>

Metadata associated to this room session.


name

name: string

Name of this room.


previewUrl

Optional previewUrl: string

URL to the room preview.


layoutName

Optional layoutName: string

Current layout name used in the room.


roomId

roomId: string

ID of the room associated to this room session.


Methods

audioMute

audioMute(params): Promise<void>

Mutes the audio of a given member for all other participants.

Parameters

NameTypeDescription
paramsObject-
params.memberIdstringID of the member to mute.

Returns

Promise<void>

Example

In this example, we mute the audio of a member as soon as they join the room. This example assumes that there is a RoomSession already active.

import { SignalWire } from "@signalwire/realtime-api";

// Initialize the SignalWire client
const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" })

// Access the video client from the main client
const videoClient = client.video;

// Setup listener for when a room starts
await videoClient.listen({

onRoomStarted: async (roomSession) => {
console.log("Room started", roomSession.displayName);
await roomSession.listen({
// Listen for when a member joins the room
onMemberJoined: async (member) => {
// Mute member's audio
console.log(`Muting ${member.id}'s audio`);
await roomSession.audioMute({ memberId: member.id });
}
});
},
onRoomEnded: async (roomSession) => {
console.log("Room ended", roomSession.displayName);
}
});

audioUnmute

audioUnmute(params): Promise<void>

Unmutes the microphone of a given member if it had been previously muted.

Parameters

NameTypeDescription
paramsObject-
params.memberIdstringID of the member to unmute.

Returns

Promise<void>

Example

In this example, we mute the audio of a member as soon as they join the room. After 5 seconds, we unmute the member's audio. This example assumes that there is a RoomSession already active and that members are joining the room.

import { SignalWire } from "@signalwire/realtime-api";

// Initialize the SignalWire client
const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" })

// Access the video client from the main client
const videoClient = client.video;

// Setup listener for when a room starts
await videoClient.listen({
onRoomStarted: async (roomSession) => {
console.log("Room started", roomSession.displayName);
await roomSession.listen({
// Listen for when a member joins the room
onMemberJoined: async (member) => {
// Mute member's audio
console.log(`Muting ${member.id}'s audio`);
await roomSession.audioMute({ memberId: member.id });
// Unmute member's audio after 5 seconds
setTimeout(() => {
console.log(`Unmuting ${member.id}'s audio`);
roomSession.audioUnmute({ memberId: member.id });
}, 5000);
}
});
},
onRoomEnded: async (roomSession) => {
console.log("Room ended", roomSession.displayName);
}
});

deaf

deaf(params): Promise<void>

Mutes the incoming audio for a given member. The affected participant will not hear audio from the other participants anymore.

Note that in addition to making a participant deaf, this will also automatically mute the microphone of the target participant. If you want, you can then manually unmute it by calling audioUnmute.

Parameters

NameTypeDescription
paramsObject-
params.memberIdstringID of the member to affect.

Returns

Promise<void>

Example

import { SignalWire } from "@signalwire/realtime-api";

// Initialize the SignalWire client
const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" })

// Access the video client from the main client
const videoClient = client.video;

// Setup listener for when a room starts
await videoClient.listen({

onRoomStarted: async (roomSession) => {
console.log("Room started", roomSession.displayName);
await roomSession.listen({
// Listen for when a member joins the room
onMemberJoined: async (member) => {
console.log("Member joined", member.name);
// Deafen the member
console.log("Deafing member", member.name);
await roomSession.deaf({ memberId: member.id });
}
});
},
onRoomEnded: async (roomSession) => {
console.log("Room ended", roomSession.displayName);
}
});

deleteMemberMeta

deleteMemberMeta(params): Promise<void>

Deletes the specified keys from the metadata for the specified member.

Parameters

NameTypeDescription
paramsObject-
params.memberId?stringID of the member to affect. If omitted, affects the default device in the local client.
params.keysstring[]The keys to remove.

Returns

Promise<void>

Example

In this example, we set metadata for a member as soon as they join the room. After 5 seconds, we remove the metadata for that member. Once the member's metadata is set or removed, we log the metadata for that member with the onMemberUpdated event. This example assumes that there is a RoomSession already active and that members are joining the room.

import { SignalWire } from "@signalwire/realtime-api";

// Initialize the SignalWire client
const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" })

// Access the video client from the main client
const videoClient = client.video;

// Setup listener for when a room starts
await videoClient.listen({
onRoomStarted: async (roomSession) => {
console.log("Room started", roomSession.displayName);
await roomSession.listen({
// Listen for when a member joins the room
onMemberJoined: async (member) => {
console.log("Member joined", member.name);

// set metadata for the member
console.log("Setting metadata for member", member.name);
await roomSession.setMemberMeta({
memberId: member.id,
meta: {
name: member.name,
foo: "red"
}
})

// remove metadata for the member in 5 seconds
setTimeout(async () => {
console.log("Removing metadata for member", member.name);
await roomSession.deleteMemberMeta({
memberId: member.id,
keys: ["foo"]
})
}, 5000)
},
onMemberUpdated: async (member) => {
// Listen for when a member updates their metadata
console.log("Member updated", member.name);
console.log(`Meta data for ${member.name}\n ${JSON.stringify( member.meta, null, 2)}`)
},
});
},
onRoomEnded: async (roomSession) => {
console.log("Room ended", roomSession.displayName);
}
});

deleteMeta

deleteMeta(keys): Promise<void>

Deletes the specified keys from the metadata for this RoomSession.

Parameters

NameTypeDescription
keysstring[]The keys to remove.

Returns

Promise<void>

Example

In this example, we set metadata for a room as soon as it starts. After 5 seconds, we remove the metadata for that room. Once the room's metadata is set or removed, we log the metadata for that room. This example assumes that there is a RoomSession already active and that members are joining the room.

import { SignalWire } from "@signalwire/realtime-api";

// Initialize the SignalWire client
const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" })


// Access the video client from the main client
const videoClient = client.video;

// Setup listener for when a room starts
await videoClient.listen({
onRoomStarted: async (roomSession) => {
console.log("Room started", roomSession.displayName);
await roomSession.setMeta({
"foo": "bar",
"roomName": roomSession.displayName
});
let roomMeta = await roomSession.getMeta()
console.log("Room meta", roomMeta);

// delete room meta after 5 seconds

setTimeout(async () => {
console.log("Deleting room meta");
await roomSession.deleteMeta(["foo"]);
roomMeta = await roomSession.getMeta()
console.log("Room meta", roomMeta);
}, 5000);

},
onRoomEnded: async (roomSession) => {
console.log("Room ended", roomSession.displayName);
}
});

demote

demote(params): Promise<void>

Demotes a participant from "member" to "audience". See promote.

Parameters

NameTypeDescription
paramsObject-
params.memberIdstringID of the member to affect.
params.mediaAllowed?"all" | "audio-only" | "video-only"Specifies the media that the client will be allowed to receive. An audience participant cannot send any media.

Returns

Promise<void>

Example

In this example, we demote a member to audience as soon as they join the room. This example assumes that there is a RoomSession already active and that members are joining the room.

import { SignalWire } from "@signalwire/realtime-api";

// Initialize the SignalWire client
const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" })

// Access the video client from the main client
const videoClient = client.video;

// Setup listener for when a room starts
await videoClient.listen({
onRoomStarted: async (roomsession) => {
console.log("Room started", roomsession.displayName);
await roomsession.listen({
// Listen for when a member is updated
onMemberJoined: async (member) => {
console.log("Member joined", member.name);
// Demote member to audience
console.log(`Demoting ${member.name} to audience`);
roomsession.demote({
memberId: member.id,
mediaAllowed: "audio-only"
});
}
});
}
})

getLayouts

getLayouts(): Promise<{ layouts: string[] }>

Returns a list of available layouts for the room. To set a room layout, use setLayout.

Returns

Promise<{ layouts: string[] }>

A promise that resolves to an object containing the list of available layouts for the room.

Example

In this example, we wait for a room to start and then get the available layouts for that room. This example assumes that there is a RoomSession already active and that members are joining the room.

import { SignalWire } from "@signalwire/realtime-api";

// Initialize the SignalWire client
const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" })


// Access the video client from the main client
const videoClient = client.video;

// Setup listener for when a room starts
await videoClient.listen({
onRoomStarted: async (roomsession) => {
console.log("Room started", roomsession.displayName);
const layouts = await roomsession.getLayouts();
console.log("Layouts", layouts.layouts);
}
})

getMembers

getMembers(): Promise<{ members: RoomSessionMember[] }>

Returns a list of members currently in the room.

Returns

Promise<{ members: RoomSessionMemberEntity[] }>

A promise that resolves to an object containing the list of RoomSessionMembers in the room.

Example

In this example, we wait for a room to start and then get the members in that room. This example assumes that there is a RoomSession already active and that members are joining the room.

import { SignalWire } from "@signalwire/realtime-api";

// Initialize the SignalWire client
const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" })

// Access the video client from the main client
const videoClient = client.video;

// Setup listener for when a room starts
await videoClient.listen({
onRoomStarted: async (roomsession) => {
console.log("Room started", roomsession.displayName);
// get all members in the room
const members = await roomsession.getMembers();

// log the members names
members.members.forEach((member) => console.log(member.name));
}
})

getMemberMeta

getMemberMeta(): Promise<{ meta: RoomSessionMember.meta }>

Returns the metadata assigned to the specified member.

Parameters

NameTypeDescription
paramsObject-
params.memberIdstringID of the member for which to obtain the metadata.

Returns

Promise<{ meta: RoomSessionMember.meta }>

A promise that resolves to an object containing the metadata assigned to the specified RoomSessionMember.

Example

import { SignalWire } from "@signalwire/realtime-api";

// Initialize the SignalWire client
const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" })


// Access the video client from the main client
const videoClient = client.video;

// Setup listener for when a room starts
await videoClient.listen({
onRoomStarted: async (roomsession) => {
console.log("Room started", roomsession.displayName);

roomsession.listen({
onMemberJoined: async (member) => {
console.log("Member joined", member.name);
// set metadta for the member
await roomsession.setMemberMeta({
memberId: member.id,
meta: {
name: member.name,
foo: "bar"
}
});
// get member meta
const memberMeta = await roomsession.getMemberMeta({
memberId: member.id
});
console.log("Member meta", memberMeta.meta);
}
})
}
})

getMeta

getMeta(): Promise<{ meta: RoomSession.meta }>

Returns the metadata assigned to this Room Session.

Returns

Promise<{ meta: RoomSession.meta }>

A promise that resolves to a RoomSession.meta object containing the metadata assigned to this Room Session.

Example

In this example, we set metadata for a room as soon as it starts. This example assumes that there is a RoomSession already active and that members are joining the room.

import { SignalWire } from "@signalwire/realtime-api";

// Initialize the SignalWire client
const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" })

// Access the video client from the main client
const videoClient = client.video;

// Setup listener for when a room starts
await videoClient.listen({
onRoomStarted: async (roomSession) => {
console.log("Room started", roomSession.displayName);

// Set the room meta
console.log("Setting room meta");
await roomSession.setMeta({
"foo": "bar",
"roomName": roomSession.displayName
});

// Get the room meta
let roomMeta = await roomSession.getMeta()
console.log("Room meta", roomMeta);
},
onRoomEnded: async (roomSession) => {
console.log("Room ended", roomSession.displayName);
}
});

getPlaybacks

getPlaybacks(): Promise<{ playbacks: RoomSessionPlayback }>

Obtains a list of playbacks for the current room session.

Returns

Promise<{ playbacks: RoomSessionPlayback }>

A promise that resolves to an object containing the list of RoomSessionPlayback objects.

Example

In this example, we wait for a room to start and then start a playback in that room. When a second member joins the roomSession, we use getPlaybacks to get the list of playback objects. We then loop through the list of playbacks and print out the state, url, and id of each playback. This example assumes that there is a RoomSession already active and that members are joining the room.

import { SignalWire } from "@signalwire/realtime-api";

// Initialize the SignalWire client
const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" })


// Access the video client from the main client
const videoClient = client.video;

// Setup listener for when a room starts
await videoClient.listen({
onRoomStarted: async (roomSession) => {
console.log("Room started", roomSession.displayName);

// play wait music
await roomSession.play({
url: "https://cdn.signalwire.com/default-music/welcome.mp3",
listen: {
onStarted: () => console.log("Playback started"),
onUpdated: (playback) => console.log("Playback updated", playback.state),
onEnded: () => console.log("Playback ended")
}
}).onStarted();

// Setup listener for when a member joins
await roomSession.listen({
onMemberJoined: async (member) => {
console.log("Member joined", member.name);

// get roomSessions playbacks
let roomPlaybacks = await roomSession.getPlaybacks();

// loop through playbacks and print out state, url, and id
roomPlaybacks.playbacks.forEach((playback) => {
console.log(playback.state, playback.url, playback.id);
});
},
onMemberLeft: (member) => {
console.log("Member left", member.name);
},
});
},
onRoomEnded: async (roomSession) => {
console.log("Room ended", roomSession.displayName);
}
});

getRecordings

getRecordings(): Promise<{ recordings: RoomSessionRecording }>

Obtains a list of recordings for the current room session.

Returns

Promise<{ recordings: RoomSessionRecording }>

A promise that resolves to an object containing the list of RoomSessionRecording objects.

Example

In this example, we wait for a room to start and then start a recording in that room. After 5 seconds, we then use getRecordings to get the list of recording objects. We then loop through the list of recordings and print out the state and id of each recording. Afterwards, we stop the recording. This example assumes that there is a RoomSession already active and that members are joining the room.

import { SignalWire } from "@signalwire/realtime-api";

// Initialize the SignalWire client
const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" })


// Access the video client from the main client
const videoClient = client.video;

// Setup listener for when a room starts
await videoClient.listen({
onRoomStarted: async (roomSession) => {
console.log("Room started", roomSession.displayName);

let roomRecording = roomSession.startRecording({
listen: {
onStarted: () => {
console.log("Recording started");
},
onUpdated: (recording) => {
console.log("Recording updated", recording.state);
},
onEnded: (recording) => {
console.log(`Recording ended.
Recording State: ${recording.state}.
Recording Id: ${recording.id}`);

},
}
})
setTimeout( async () => {
// Get the roomSession recordings
let rooomRecordings = await roomSession.getRecordings();
rooomRecordings.recordings.forEach(recording => {
console.log("Active Recording", recording.id, recording.state);
});

// Stop recording after 5 seconds
roomRecording.stop();
}, 5000);

// Setup listener for when a member joins
await roomSession.listen({
onMemberJoined: async (member) => {
console.log("Member joined", member.name);

},
onMemberLeft: (member) => {
console.log("Member left", member.name);
},
});
},
onRoomEnded: async (roomSession) => {
console.log("Room ended", roomSession.displayName);
}
});

getStreams

getStreams(): Promise<{ streams: RoomSessionStream }>

Obtains a list of active streams for this RoomSession. These are RTMP streams of the audio/video content of this room, which will be sent to an external party (e.g., to YouTube).

Returns

Promise<{ streams: RoomSessionStream }> - See RoomSessionStream for more information.

Example

In this example, we wait for a room to start and then start a stream in that room. We then use getStreams to get the list of stream objects. We then loop through the list of streams and print out the state and id of each stream. Afterwards, we stop the stream after 10 seconds. This example assumes that there is a RoomSession already active and that members are joining the room.

import { SignalWire } from "@signalwire/realtime-api";

// Initialize the SignalWire client
const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" })


// Access video client from the main client
const videoClient = client.video;

// Setup listener for when a room starts
await videoClient.listen({
onRoomStarted: async (roomSession) => {
console.log("Room started", roomSession.displayName);

roomSession.startStream({
url: "rtmp://example.com/stream"
})

await roomSession.listen({
onStreamStarted: async (stream) => {
console.log("Stream started", stream.state);

// get active streams
const activeStreams = roomSession.getStreams();

(await activeStreams).streams.forEach((stream) => {
console.log(`Active Steam: ${stream.id}, ${stream.state}`);
});

// Wait 10 seconds and stop the stream

setTimeout(() => {
console.log("Stopping stream");
stream.stop();
}, 10000);
},
onStreamEnded: (stream) => {
console.log("Stream ended", stream.id, stream.state);
},
});
},
onRoomEnded: async (roomSession) => {
console.log("Room ended", roomSession.displayName);
}
});

listen

listen({ event: Callback }): Promise<RoomSession Events>

Enables listening for events on this room session.

Parameters

NameTypeDescription
paramsObjectObject containing the parameters of the method.
params.topicsobject[]List of topics to listen to.
params.EVENTCallbackThe event to listen to. List og events can be found here.
Example event: (E.g: onRoomStarted

Returns

Promise<RoomSession Events>

Emits events for the specified event. See RoomSession Events for a list of valid events and their return types.

Example

In this example, we wait for a room ton start and then log the room's name. This example assumes that there is a RoomSession already active and that members are joining the room.

import { SignalWire } from "@signalwire/realtime-api";

// Initialize the SignalWire client
const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" })

// Access the video client from the main client
const videoClient = client.video;

// Setup listener for when a room starts
await videoClient.listen({
onRoomStarted: async (roomsession) => {
console.log("Room Started", roomsession.displayName);
}
}
);

lock

lock(params): Promise<void>

Locks the room. This prevents new participants from joining the room.

Returns

Promise<void>

Example

In this example, we wait for a room to start and then lock the room. This prevents new participants from joining the room. This example assumes that there is a RoomSession already active and that members are joining the room.

import { SignalWire } from "@signalwire/realtime-api";

const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" })

const videoClient = client.video;

// Setup listener for when a room starts
await videoClient.listen({
onRoomStarted: async (roomsession) => {
// Lock the room
console.log('Locking room');
await roomsession.lock();
}
})

play

play(params): Promise<RoomSessionPlayback>

Start a playback in the room. You can use the returned RoomSessionPlayback object to control the playback (e.g., pause, resume, setVolume and stop).

Parameters

NameTypeDescription
paramsObject-
params.urlstringThe url (http, https, rtmp, rtmps) of the stream to reproduce.
params.seekPosition?numberThe starting timecode in milliseconds for playback. Defaults to 0.
params.positions?VideoPositionsPositions to assign as soon as the playback starts. You can use the special keyword self to refer to the id of the playback.
params.layout?stringLayout to change to when the playback starts.
params.listen?ObjectObject of event listeners. See RoomSessionPlayback Events for a list of valid events.
Example event: (E.g: onStarted)

Returns

Promise<RoomSessionPlayback>

A promise that resolves to a RoomSessionPlayback object.

Example

In this example, we wait for a room to start and then play a video in that room. When a second member joins the roomSession, we stop the playback. This example assumes that there is a RoomSession already active and that members are joining the room.

import { SignalWire } from "@signalwire/realtime-api";

// Initialize the SignalWire client
const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" })

// Access the video client from the main client
const videoClient = client.video;

// Setup listener for when a room starts
await videoClient.listen({
onRoomStarted: async (roomSession) => {
console.log("Room started", roomSession.displayName);

// play wait music
let roomPlayback = roomSession.play({
url: "https://cdn.signalwire.com/default-music/welcome.mp3",
listen: {
onStarted: () => console.log("Playback started"),
onUpdated: (playback) => console.log("Playback updated", playback.state),
onEnded: () => console.log("Playback ended")
}
});
await roomSession.listen({
onMemberJoined: (member) => {
console.log("Member joined", member.name);
roomPlayback.stop();
},
onMemberLeft: (member) => {
console.log("Member left", member.name);
},
});
},
onRoomEnded: async (roomSession) => {
console.log("Room ended", roomSession.displayName);
}
});

promote

promote(params): Promise<void>

Promotes a participant from "audience" to "member". See demote.

Parameters

NameTypeDescription
paramsObject-
params.memberIdstringID of the audience participant to promote.
params.joinAudioMuted?booleanForce the member's audio to be muted right after the promotion.
params.joinVideoMuted?booleanForce the member's video to be muted right after the promotion.
params.mediaAllowed?"all" | "audio-only" | "video-only"Specifies the media that the client will be allowed to send. A member participant can always receive all media.
params.meta?Record<record-type><string, unknown>Metadata to assign to the member.
params.permissions?string[]List of permissions to grant when the Audience participant will become a Member.

Returns

Promise<void>

Example

In this example, we demote a member to audience as soon as they join the room. After 10 seconds, we promote the member back to a roomSession member. This example assumes that there is a RoomSession already active and that members are joining the room.

import { SignalWire } from "@signalwire/realtime-api";

// Initialize the SignalWire client
const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" })


// Access the video client from the main client
const videoClient = client.video;

// Setup listener for when a room starts
await videoClient.listen({
onRoomStarted: async (roomsession) => {
console.log("Room started", roomsession.displayName);
await roomsession.listen({
// Listen for when a member is updated
onMemberJoined: async (member) => {
console.log("Member joined", member.id, member.name);
// Demote member to audience
console.log(`Demoting ${member.id} to audience`);
await roomsession.demote({
memberId: member.id,
mediaAllowed: "audio-only"
});
// wait 10 seconds then promote the member back to a roomSession member
setTimeout(async () => {
// Promote the audience participant to a member
console.log(`Promoting ${member.name} to member`);
await roomsession.promote({
memberId: member.id,
mediaAllowed: "all",
joinAudioMuted: true,
joinVideoMuted: false,
permissions: [
"room.self.audio_mute",
"room.self.audio_unmute",
"room.self.video_mute",
"room.self.video_unmute",
"room.list_available_layouts",
]
});
}, 10000);
}
});
}
})

removeAllMembers

removeAllMembers(): Promise<void>

Removes all the members from this room session. The room session will end.

Returns

Promise<void>

Example

In this example, we wait for a room to start and then remove all the members from that room after 5 seconds. This example assumes that there is a RoomSession already active and that members are joining the room.

import { SignalWire } from "@signalwire/realtime-api";

// Initialize the SignalWire client
const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" })


// Access the video client from the main client
const videoClient = client.video;

// Setup listener for when a room starts
await videoClient.listen({
onRoomStarted: async (roomsession) => {
console.log("Room started", roomsession.displayName);

// Remove all members from the room after 5 seconds
setTimeout(async () => {
console.log("Removing all members from room");
await roomsession.removeAllMembers();
}, 5000);
}
})

removeMember

removeMember(params): Promise<void>

Removes a specific participant from the room.

Parameters

NameTypeDescription
paramsObject-
params.memberIdstringID of the member to remove.

Returns

Promise<void>

Example

In this example, we wait for a room to start and then remove the second member that joins the room after 5 seconds. This example assumes that there is a RoomSession already active and that members are joining the room.

import { SignalWire } from "@signalwire/realtime-api";

// Initialize the SignalWire client
const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" })


// Access the video client from the main client
const videoClient = client.video;

// Setup listener for when a room starts
await videoClient.listen({
onRoomStarted: async (roomsession) => {
console.log("Room started", roomsession.displayName);

// listen for when new participants join the room
roomsession.listen({
onMemberJoined: async (member) => {
console.log("Member joined", member.name);

// remove the member from the room after 5 seconds

setTimeout(async () => {
console.log("Removing member", member.name);
roomsession.removeMember({
memberId: member.id,
});
}, 5000);
},
});
}
});

setHideVideoMuted

setHideVideoMuted(value): Promise<void>

Show or hide muted videos in the room layout. Members that have been muted via videoMute will not appear in the video stream, instead of appearing as a mute image, if this setting is enabled.

Muted videos are shown by default.

Parameters

NameTypeDescription
valuebooleanWhether to hide muted videos in the room layout.

Returns

Promise<void>

Example

In this example, we wait for a room to start and then hide muted videos in the room layout. If you mute your video, you will not appear in the video stream, instead of appearing as a mute image. This example assumes that there is a RoomSession already active and that members are joining the room.

import { SignalWire } from "@signalwire/realtime-api";

// Initialize the SignalWire client
const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" })


// Access the video client from the main client
const videoClient = client.video;

// Setup listener for when a room starts
await videoClient.listen({
onRoomStarted: async (roomsession) => {
console.log("Room started", roomsession.displayName);

// Setup listener for when a room is updated
roomsession.listen({
onRoomUpdated: async (roomsession) => {
console.log(`Updated room ${roomsession.displayName} to hide muted videos!`);
}
});
// Hide muted videos in the room layout
roomsession.setHideVideoMuted(true);
}
})

setInputSensitivity

setInputSensitivity(params): Promise<void>

Sets the input level at which the participant is identified as currently speaking.

Parameters

NameTypeDescription
paramsObject-
params.memberIdstringID of the member to affect.
params.valuenumberDesired sensitivity from 0 (lowest sensitivity, essentially muted) to 100 (highest sensitivity). The default value is 30.

Returns

Promise<void>

Example

In this example, we wait for a room to start and then set the input sensitivity for a member to 0. This example assumes that there is a RoomSession already active and that members are joining the room.

import { SignalWire } from "@signalwire/realtime-api";

// Initialize the SignalWire client
const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" })


// Access the video client from the main client
const videoClient = client.video;

// Setup listener for when a room starts
await videoClient.listen({
onRoomStarted: async (roomsession) => {
console.log("Room started", roomsession.displayName);

// Setup listener for when a room is updated
roomsession.listen({
onMemberJoined: async (member) => {
console.log("Member joined", member.name);

// Update the input sensitivity for the member
await roomsession.setInputSensitivity({
value: 0,
memberId: member.id,
});
},
onMemberUpdated: async (member) => {
console.log(`Updated input sensitivity for ${member.name, member.inputSensitivity}`);
},
})
}
});

setInputVolume

setInputVolume(params): Promise<void>

Sets the input volume for a given member (e.g., the microphone input level).

Parameters

NameTypeDescription
paramsObject-
params.memberIdstringID of the member to affect.
params.volumenumberDesired volume. Values range from -50 to 50, with a default of 0.

Returns

Promise<void>

Example

In this example, we wait for a second member to join the room and then set the input volume for that member to -50. This example assumes that there is a RoomSession already active and that members are joining the room.

import { SignalWire } from "@signalwire/realtime-api";

const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" })


const videoClient = client.video;

// Setup listener for when a room starts
await videoClient.listen({
onRoomStarted: (roomsession) => {
console.log("Room started", roomsession.displayName);

// Setup listener for when a room is updated
roomsession.listen({
onMemberJoined: (member) => {
console.log("Member joined", member.name);

// Update the input sensitivity for the member
roomsession.setInputVolume({
volume: -50,
memberId: member.id,
});
},
onMemberUpdated: (member) => {
console.log(`Updated input volume for ${member.name, member.inputVolume}`);
},
})
}
});

setLayout

setLayout(params): Promise<void>

Sets a layout for the room. You can obtain a list of available layouts with getLayouts.

Parameters

NameTypeDescription
paramsObject-
params.namestringName of the layout.
params.positions?VideoPositionsPositions to assign as soon as the new layout is set.

Returns

Promise<void>

Example

In this example, we wait for a room to start and then set the layout for that room to "6x6". This example assumes that there is a RoomSession already active and that members are joining the room.

import { SignalWire } from "@signalwire/realtime-api";

// Initialize the SignalWire client
const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" })


// Access video client from the main client
const videoClient = client.video;

// Setup listener for when a room starts
await videoClient.listen({
onRoomStarted: (roomsession) => {
console.log("Room started", roomsession.displayName);
// Set the 6x6 layout
roomsession.setLayout({
name: "6x6",
positions: {
self: 'auto'
}
});
roomsession.listen({
onRoomUpdated: (roomsession) => {
console.log("Room layout updated", roomsession.layoutName);
},
})
}
});

setMemberMeta

setMemberMeta(params): Promise<void>

Assigns custom metadata to the specified RoomSessionMember. You can use this to store metadata whose meaning is entirely defined by your application.

Note that calling this method overwrites any metadata that had been previously set on the specified member.

Parameters

NameTypeDescription
paramsObject-
params.memberIdstringID of the member to affect.
params.metaRecord<record-type><string, unknown>The medatada object to assign to the member.

Returns

Promise<void>

Example

In this example, we set metadata for a member as soon as they join the room. Once the member's metadata is set, we log the metadata for that member with the onMemberUpdated event. This example assumes that there is a RoomSession already active and that members are joining the room.

import { SignalWire } from "@signalwire/realtime-api";

// Initialize the SignalWire client
const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" });

// Access video client from the main client
const videoClient = client.video;

// Setup listener for when a room starts
await videoClient.listen({
onRoomStarted: async (roomsession) => {
console.log("Room started", roomsession.displayName);

roomsession.listen({
onMemberJoined: async (member) => {
console.log("Member joined", member.name);
// set metadta for the member
await roomsession.setMemberMeta({
memberId: member.id,
meta: {
name: member.name,
foo: "bar",
},
});
// get member meta
const memberMeta = await roomsession.getMemberMeta({
memberId: member.id
});
console.log("Member meta", memberMeta.meta);
},
})
}
})

setMemberPosition

setMemberPosition(params): Promise<void>

Assigns a position in the layout to the specified member.

Parameters

NameTypeDescription
paramsObject-
params.memberIdstringID of the member to affect.
params.positionVideoPositionPosition to assign in the layout.

Returns

Promise<void>

Example

In this example, we wait for a room to start and then set the roomlayout to "6x6". When a second member joins the room, we set the position of that member to "off-canvas". This example assumes that there is a RoomSession already active and that members are joining the room.

import { SignalWire } from "@signalwire/realtime-api";

// Initialize the SignalWire client
const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" });

// Access video client from the main client
const videoClient = client.video;

// Setup listener for when a room starts
await videoClient.listen({
onRoomStarted: async (roomsession) => {

// Set the layout of the room
roomsession.setLayout({
name: "6x6",
});

// listens for when a member joins the room
await roomsession.listen({

onMemberJoined: async (member) => {
console.log("Member joined", member.name);
// Set position for the member
roomsession.setMemberPosition({
memberId: member.id,
position: "off-canvas"
});
},
onMemberUpdated: async (member) => {
console.log(`Updated ${member.name} position`);
},

onRoomUpdated: async (room) => {
console.log(`Room updated to ${room.layoutName}`);
},
});
}
})

setMeta

setMeta(meta): Promise<void>

Assigns custom metadata to the RoomSession. You can use this to store metadata whose meaning is entirely defined by your application.

Note that calling this method overwrites any metadata that had been previously set on this RoomSession.

Parameters

NameTypeDescription
metaRecord<record-type><string, unknown>The metadata object to assign to the RoomSession.

Returns

Promise<void>

Example

In this example, we set metadata for a room as soon as it starts and then log the metadata for that room. This example assumes that there is a RoomSession already active and that members are joining the room.

import { SignalWire } from "@signalwire/realtime-api";

// Initialize the SignalWire client
const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" })

// Access the video client from the main client
const videoClient = client.video;

// Setup listener for when a room starts
await videoClient.listen({
onRoomStarted: async (roomSession) => {
console.log("Room started", roomSession.displayName);

// Set the room meta
console.log("Setting room meta");
await roomSession.setMeta({
"foo": "bar",
"roomName": roomSession.displayName
});

// Get the room meta
let roomMeta = await roomSession.getMeta()
console.log("Room meta", roomMeta);
},
onRoomEnded: async (roomSession) => {
console.log("Room ended", roomSession.displayName);
}
});

setOutputVolume

setOutputVolume(params): Promise<void>

Sets the output volume for the member (e.g., the speaker output level).

Parameters

NameTypeDescription
paramsObject-
params.memberIdstringID of the member to affect.
params.volumenumberDesired volume. Values range from -50 to 50, with a default of 0.

Returns

Promise<void>

Example

In this example, we wait for a room to start and then wait for a member to join the room. When a member joins the room, we set the output volume for that member to -50. This example assumes that there is a RoomSession already active and that members are joining the room.

import { SignalWire } from "@signalwire/realtime-api";

// Initialize the SignalWire client
const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" });

// Access video client from the main client
const videoClient = client.video;

// Setup listener for when a room starts
await videoClient.listen({
onRoomStarted: async (roomsession) => {

console.log("Room started", roomsession.displayName);

roomsession.listen({
onMemberJoined: async (member) => {
console.log("Member joined", member.displayName);
// set output volume to -50dB
console.log("Setting output volume to -50dB for", member.name);
await roomsession.setOutputVolume({
volume: -50,
memberId: member.id
});
},
onMemberUpdated: async (member) => {
console.log(`${member.name} output volume is now ${member.outputVolume}`);
},
})
}
});

setPositions

setPositions(params): Promise<void>

Assigns a position in the layout for multiple members.

Parameters

NameTypeDescription
paramsObject-
params.positionsVideoPositionsMapping of member IDs and positions to assign.

Returns

Promise<void>

Example

In this example, we wait for a room to start and then set the roomlayout to "6x6". When a second member joins the room, we set the position of all older members to "off-canvas". This example assumes that there is a RoomSession already active and that members are joining the room.

import { SignalWire } from "@signalwire/realtime-api";

// Initialize the SignalWire client
const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" });

// Access video client from the main client
const videoClient = client.video;

// Setup listener for when a room starts
await videoClient.listen({
onRoomStarted: (roomsession) => {
console.log("Room started", roomsession.displayName);
// Set the 6x6 layout
roomsession.setLayout({
name: "6x6",
positions: {
self: 'auto'
}
});
roomsession.listen({
onRoomUpdated: (roomsession) => {
console.log("Room layout updated", roomsession.layoutName);
},
onMemberJoined: async (member) => {
console.log("Member joined", member.name);

// Get all members and loop through them ans save all old members to an array
const members = await roomsession.getMembers();

// Create an object to hold all member positions
const positions = {
...members.members
.filter(memberItem => memberItem.id !== member.id) // Filter out the member with member.id
.reduce((acc, memberItem) => {
acc[memberItem.id] = 'off-canvas';
return acc;
}, {})
};

console.log("Updating member positions...")
// Update all old members positions to off canvas and the new member to be automatically positioned

await roomsession.setPositions({
positions: positions
});
},
onMemberUpdated: (member) => {
console.log(`Member ${member.name} updated`);
}
})
}
});

setPrioritizeHandraise

setPrioritizeHandraise(param): Promise<boolean>

Set whether to prioritize hand-raise or not. Users with raised hands will be shown in the main video area over other participants who don't have their hand raised.

Parameters

NameTypeDescription
parambooleanWhether to prioritize participants on the canvas with their hand-raised. Default: true. If omitted, the hand status is toggled to the opposite of the current status.

Returns

Promise<boolean>

Example

In this example, we wait for a room to start and then set the room to prioritize hand-raise.

import { SignalWire } from "@signalwire/realtime-api";

// Initialize the SignalWire client
const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" });

// Access video client from the main client
const videoClient = client.video;

// Setup listener for when a room starts

await videoClient.listen({
onRoomStarted: async (roomSession) => {
console.log("Room started", roomSession.displayName);

// Set the room to prioritize hand-raise
await roomSession.setPrioritizeHandraise(true);
}
});

setRaisedHand

setRaisedHand(params): Promise<void>

Sets the raised hand status for the current member.

Parameters

NameTypeDescription
paramsObject-
params.memberidstringID of the member to affect.
params.raised?booleanWhether to raise or lower the hand. Default: true. If omitted, the hand status is toggled to the opposite of the current status.

Returns

Promise<void>

Example

In this example, we wait for a member to join the room and then set the raised hand status for that member to true.

import { SignalWire } from "@signalwire/realtime-api";

// Initialize the SignalWire client
const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" });

// Access video client from the main client
const videoClient = client.video;

// Setup listener for when a room starts
await videoClient.listen({
onRoomStarted: async (roomSession) => {
console.log("Room started", roomSession.displayName);

// Setup listener for when a member joins the room
await roomSession.listen({
onMemberJoined: async (member) => {
console.log("Member joined", member.name);

// Set the raised hand status for the member
await roomSession.setRaisedHand({
memberId: member.id,
raised: true
});
}
});
}
});

startRecording

startRecording(): Promise<RoomSessionRecording>

Starts the recording of the room. You can use the returned RoomSessionRecording object to control the recording (e.g., pause, resume, stop).

Parameters

NameTypeDescription
params?Object-
params.listen?ObjectObject of event listeners. See RoomSessionRecording Events for a list of valid events.

Returns

Promise<RoomSessionRecording>

A promise that resolves to a RoomSessionRecording object.

Example

In this example, we wait for a room to start and then start a recording in that room. We then stop the recording after 5 seconds. This example assumes that there is a RoomSession already active and that members are joining the room.

import { SignalWire } from "@signalwire/realtime-api";

// Initialize the SignalWire client
const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" });

// Access video client from the main client
const videoClient = client.video;

// Setup listener for when a room starts
await videoClient.listen({
onRoomStarted: async (roomSession) => {
console.log("Room started", roomSession.displayName);

let roomRecording = roomSession.startRecording({
listen: {
onStarted: () => {
console.log("Recording started");
},
onUpdated: (recording) => {
console.log("Recording updated", recording.state);
},
onEnded: (recording) => {
console.log(`Recording ended.
Recording State: ${recording.state}.
Recording Id: ${recording.id}`);
},
}
})
setTimeout( () => {
roomRecording.stop();
}, 5000);

// Setup listener for when a member joins
await roomSession.listen({
onMemberJoined: async (member) => {
console.log("Member joined", member.name);

},
onMemberLeft: (member) => {
console.log("Member left", member.name);
},
});
},
onRoomEnded: async (roomSession) => {
console.log("Room ended", roomSession.displayName);
}
});

startStream

startStream(): Promise<RoomSessionStream>

Starts streaming the audio/video of this room to an external service. You can use the returned RoomSessionStream object to interact with the stream.

Parameters

NameTypeDescription
paramsObject
params.urlstringRTMP or RTMPS url. This must be the address of a server accepting incoming RTMP/RTMPS streams.
params.listen?ObjectObject of event listeners. See RoomSessionStream Events for a list of valid events.

Returns

Promise<RoomSessionStream>

A promise that resolves to a RoomSessionStream object.

Example

In this example, we wait for a room to start and then start a stream in that room. We then stop the stream after 10 seconds. This example assumes that there is a RoomSession already active and that members are joining the room.

import { SignalWire } from "@signalwire/realtime-api";

// Initialize the SignalWire client
const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" });

// Access video client from the main client
const videoClient = client.video;

// Setup listener for when a room starts
await videoClient.listen({
onRoomStarted: async (roomSession) => {
console.log("Room started", roomSession.displayName);

roomSession.startStream({
url: "rtmp://example.com/stream"
})

await roomSession.listen({
onStreamStarted: async (stream) => {
console.log("Stream started", stream.state);

// Wait 10 seconds and stop the stream
setTimeout(() => {
console.log("Stopping stream");
stream.stop();
}, 10000);
},
onStreamEnded: (stream) => {
console.log("Stream ended", stream.id, stream.state);
},
});
},
onRoomEnded: async (roomSession) => {
console.log("Room ended", roomSession.displayName);
}
});

undeaf

undeaf(params): Promise<void>

Unmutes the incoming audio for a given member. The affected participant will start hearing audio from the other participants again.

Note that in addition to allowing a participants to hear the others, this will also automatically unmute the microphone of the target participant. If you want, you can then manually mute it by calling audioMute.

Parameters

NameTypeDescription
paramsObject-
params.memberIdstringID of the member to affect.

Returns

Promise<void>

Example

In this example, we mute a member when they join the room, and then unmute them after 5 seconds. This example assumes that there is a RoomSession already active and users are joining it.

import { SignalWire } from "@signalwire/realtime-api";

// Initialize the SignalWire client
const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" });

// Access video client from the main client
const videoClient = client.video;

// Setup listener for when a room starts
await videoClient.listen({

onRoomStarted: async (roomSession) => {
console.log("Room started", roomSession.displayName);
await roomSession.listen({
// Listen for when a member joins the room
onMemberJoined: async (member) => {
console.log("Member joined", member.name);
// Deafen the member
console.log("Deafing member", member.name);
await roomSession.deaf({ memberId: member.id });

// Undeafen the member after 5 seconds
setTimeout(async () => {
console.log("Undeafing member", member.name);
await roomSession.undeaf({ memberId: member.id });
}, 5000);
}
});
},
onRoomEnded: async (roomSession) => {
console.log("Room ended", roomSession.displayName);
}
});

updateMemberMeta

updateMemberMeta(params): Promise<void>

Updates a member's metadata in only the specified fields. This is different from setMemberMeta, which replaces the whole metadata object.

Parameters

NameTypeDescription
paramsObject-
params.memberId?stringID of the member to affect. If omitted, affects the current member.
params.metaRecord<record-type><string, unknown>The update to the metadata.

Returns

Promise<void>

Example

In this example, we set metadata for a member as soon as they join the room. After 5 seconds, we update the metadata for that member. This example assumes that there is a RoomSession already active and that members are joining the room.

import { SignalWire } from "@signalwire/realtime-api";

// Initialize the SignalWire client
const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" });

// Access video client from the main client
const videoClient = client.video;

// Setup listener for when a room starts
await videoClient.listen({
onRoomStarted: async (roomsession) => {
console.log("Room started", roomsession.displayName);

roomsession.listen({
onMemberJoined: async (member) => {
console.log("Member joined", member.name);
// set metadta for the member
await roomsession.setMemberMeta({
memberId: member.id,
meta: {
name: member.name,
foo: "bar",
},
});
// get member meta
const memberMeta = await roomsession.getMemberMeta({
memberId: member.id
});
console.log("Member meta", memberMeta.meta);

// update member meta after 5 seconds

setTimeout(async () => {
await roomsession.updateMemberMeta({
memberId: member.id,
meta: {
name: "New name",
foo: "foobar",
},
});
// get member meta
console.log("Member meta after update", await roomsession.getMemberMeta({
memberId: member.id
}));
}, 5000)
},
})
}
})

updateMeta

updateMeta(meta): Promise<void>

Updates the RoomSession metadata by only setting the specified fields. This is different from setMeta, which replaces the whole metadata object.

Parameters

NameTypeDescription
metaRecord<record-type><string, unknown>The update to the metadata.

Returns

Promise<void>

Example

In this example, we set metadata for a room as soon as it starts and then update the metadata for that room after 5 seconds. This example assumes that there is a RoomSession already active and that members are joining the room.

import { SignalWire } from "@signalwire/realtime-api";

// Initialize the SignalWire client
const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" });

// Access video client from the main client
const videoClient = client.video;

// Setup listener for when a room starts
await videoClient.listen({
onRoomStarted: async (roomSession) => {
console.log("Room started", roomSession.displayName);

// Set the room meta
console.log("Setting room meta");
await roomSession.setMeta({
"foo": "bar",
"roomName": roomSession.displayName
});

// Get the room meta
let roomMeta = await roomSession.getMeta()
console.log("Room meta", roomMeta);

// update the room meta after 5 seconds
setTimeout(async () => {
console.log("Updating room meta");
await roomSession.setMeta({
"foo": "bar",
"roomName": roomSession.displayName,
"updated": true
});
console.log("Room meta Updated:", await roomSession.getMeta());
}, 5000);
},
onRoomEnded: async (roomSession) => {
console.log("Room ended", roomSession.displayName);
}
});

unlock

unlock(): Promise<void>

Unlocks the room if it had been previously locked. This allows new participants to join the room.

Returns

Promise<void>

Example

In this example, we lock a room when it starts and then unlock it after 20 seconds. This example assumes that there is a RoomSession already active and users are joining it.

import { SignalWire } from "@signalwire/realtime-api";

const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" })


const videoClient = client.video;

// Setup listener for when a room starts
await videoClient.listen({
onRoomStarted: async (roomsession) => {
// Lock the room
console.log('Locking room');
await roomsession.lock();

// unlock the room after 20 seconds

setTimeout(async () => {
console.log('Unlocking room');
await roomsession.unlock();
}, 20000);

roomsession.listen({
onMemberJoined: async (member) => {
console.log('Member joined', member.name);
},
onMemberLeft: async (member) => {
console.log('Member left', member.name);
},
})
}
})

videoMute

videoMute(params): Promise<void>

Puts the video of a given member on mute. Participants will see a mute image instead of the video stream.

Parameters

NameTypeDescription
paramsObject-
params.memberIdstringID of the member to mute.

Returns

Promise<void>

Example

In this example, we wait for a room to start and then wait for a second member to join the room. When a second member joins the room, we mute the video of that member. This example assumes that there is a RoomSession already active and that members are joining the room.

import { SignalWire } from "@signalwire/realtime-api";

// Initialize the SignalWire client
const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" });

// Access video client from the main client
const videoClient = client.video;

// Setup listener for when a room starts
await videoClient.listen({
onRoomStarted: async (roomSession) => {
console.log("Room started", roomSession.displayName);

await roomSession.listen({
onMemberJoined: (member) => {
console.log("Member joined", member.name);

// Video mute the member
roomSession.videoMute({
memberId: member.id,
})
},
onMemberUpdated: (member) => {
console.log("Member mute status updated", member.name, member.videoMuted);
},
});
}
});

videoUnmute

videoUnmute(params): Promise<void>

Unmutes the video of a given member if it had been previously muted. Participants will start seeing the video stream again.

Parameters

NameTypeDescription
paramsObject-
params.memberIdstringID of the member to unmute.

Returns

Promise<void>

Example

In this example, we wait for a room to start and then wait for a second member to join the room. When a second member joins the room, we mute the video of that member. After 5 seconds, we unmute the video of that member. This example assumes that there is a RoomSession already active and that members are joining the room.

import { SignalWire } from "@signalwire/realtime-api";

// Initialize the SignalWire client
const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" });

// Access video client from the main client
const videoClient = client.video;

// Setup listener for when a room starts
await videoClient.listen({
onRoomStarted: async (roomSession) => {
console.log("Room started", roomSession.displayName);

await roomSession.listen({
onMemberJoined: (member) => {
console.log("Member joined", member.name);

// Video mute the member

roomSession.videoMute({
memberId: member.id,
})

setTimeout(() => {
console.log("Unmuting video for member", member.name)
// Video unmute the member
roomSession.videoUnmute({
memberId: member.id,
})
}, 5000)
},
onMemberUpdated: (member) => {
console.log("Member mute status updated", member.name, member.v);
},
});
}
});

Events

You can use this object to subscribe to the following events.

onRoomSubscribed

RoomSession.listen({ onRoomSubscribed: Callback })

Emitted when the room session is subscribed too. Your event handler will be called with an instance of the RoomSession object.

Parameters

NameType
roomSessionRoomSession

onRoomStarted

RoomSession.listen({ onRoomStarted: Callback })

tip

This event is emitted when the first participant joins the room.

Emitted when the room session is started. Your event handler will be called with an instance of the RoomSession object.

Parameters

NameType
roomSessionRoomSession

onRoomUpdated

RoomSession.listen({ onRoomUpdated: Callback })

Emitted when the room session is updated. Your event handler will be called with an instance of the RoomSession object.

Parameters

NameType
roomSessionRoomSession

onRoomEnded

RoomSession.listen({ onRoomEnded: Callback })

Emitted when the room session is ended. Your event handler will be called with an instance of the RoomSession object.

Parameters

NameType
roomSessionRoomSession

onRoomAudienceCount

RoomSession.listen({ onRoomAudienceCount: Callback })

Emitted periodically, and when the audience count of the room changes. Your event handler will be called with an instance of the VideoRoomAudienceCount object.

Parameters

NameTypeDescription
paramsObject-
params.room_session_idstringID of the room session.
params.room_idstringID of the room.
params.totalnumberTotal number of audience members.

onLayoutChanged

RoomSession.listen({ onLayoutChanged: Callback })

Emitted when the layout of the room changes. Your event handler will be called with an instance of the VideoLayOutChanged object.

Parameters

NameTypeDescription
paramsObject-
params.room_session_idstringID of the room session.
params.room_idstringID of the room.
params.layoutstringName of the new layout.

onMemberJoined

RoomSession.listen({ onMemberJoined: Callback })

tip

This event is only emitted when the room session has already been started. This means the first participant to join the room will not trigger this event.

Emitted when a member joins the room. Your event handler will be called with an instance of the RoomSessionMember object.

Parameters

NameType
memberRoomSessionMember

onMemberUpdated

RoomSession.listen({ onMemberUpdated: Callback })

Emitted when a member in the room is updated. Your event handler will be called with an instance of the RoomSessionMember object.

Parameters

NameType
memberRoomSessionMember

onMemberListUpdated

RoomSession.listen({ onMemberListUpdated: Callback })

Emitted when the list of members in the room is updated. Your event handler will be called with an instance of the RoomSessionMember object.

Parameters

NameType
memberRoomSessionMember

onMemberLeft

RoomSession.listen({ onMemberLeft: Callback })

Emitted when a member leaves the room. Your event handler will be called with an instance of the RoomSessionMember object.

Parameters

NameType
memberRoomSessionMember

onMemberDeaf

RoomSession.listen({ onMemberDeaf: Callback })

Emitted when a member in the room deafens status changes. Your event handler will be called with an instance of the RoomSessionMember object.

Parameters

NameType
memberRoomSessionMember

onMemberVisible

RoomSession.listen({ onMemberVisible: Callback })

Emitted when a member in the room visibility changes. Your event handler will be called with an instance of the RoomSessionMember object.

Parameters

NameType
memberRoomSessionMember

onMemberAudioMuted

RoomSession.listen({ onMemberAudioMuted: Callback })

Emitted when a member in the room audio state changes. Your event handler will be called with an instance of the RoomSessionMember object.

Parameters

NameType
memberRoomSessionMember

onMemberVideoMuted

RoomSession.listen({ onMemberVideoMuted: Callback })

Emitted when a member in the room video state changes. Your event handler will be called with an instance of the RoomSessionMember object.

Parameters

NameType
memberRoomSessionMember

onMemberInputVolume

RoomSession.listen({ onMemberInputVolume: Callback })

Emitted when a member in the room input volume changes. Your event handler will be called with an instance of the RoomSessionMember object.

Parameters

NameType
memberRoomSessionMember

onMemberOutputVolume

RoomSession.listen({ onMemberOutputVolume: Callback })

Emitted when a member in the room output volume changes. Your event handler will be called with an instance of the RoomSessionMember object.

Parameters

NameType
memberRoomSessionMember

onMemberInputSensitivity

RoomSession.listen({ onMemberInputSensitivity: Callback })

Emitted when a member in the room input sensitivity changes. Your event handler will be called with an instance of the RoomSessionMember object.

Parameters

NameType
memberRoomSessionMember

onMemberTalking

RoomSession.listen({ onMemberTalking: Callback })

Emitted when a member in the room talking status changes. Your event handler will be called with an instance of the RoomSessionMember object.

Parameters

NameType
memberRoomSessionMember

onMemberTalkingStarted

RoomSession.listen({ onMemberTalkingStarted: Callback })

Emitted when a member in the room starts talking. Your event handler will be called with an instance of the RoomSessionMember object.

Parameters

NameType
member[RoomSessionMember](./video-roomsessionmember.md

onMemberTalkingEnded

RoomSession.listen({ onMemberTalkingEnded: Callback })

Emitted when a member in the room stops talking. Your event handler will be called with an instance of the RoomSessionMember object.

Parameters

NameType
member[RoomSessionMember](./video-roomsessionmember.md

onPlaybackStarted

RoomSession.listen({ onPlaybackStarted: Callback })

Emitted when a playback starts in the room. Your event handler will be called with an instance of the RoomSessionPlayback object.

Parameters

NameType
playbackRoomSessionPlayback

onPlaybackUpdated

RoomSession.listen({ onPlaybackUpdated: Callback })

Emitted when a playback in the room is updated. Your event handler will be called with an instance of the RoomSessionPlayback object.

Parameters

NameType
playbackRoomSessionPlayback

onPlaybackEnded

RoomSession.listen({ onPlaybackEnded: Callback })

Emitted when a playback in the room ends. Your event handler will be called with an instance of the RoomSessionPlayback object.

Parameters

NameType
playbackRoomSessionPlayback

onRecordingStarted

RoomSession.listen({ onRecordingStarted: Callback })

Emitted when a recording starts in the room. Your event handler will be called with an instance of the RoomSessionRecording object.

Parameters

NameType
recordingRoomSessionRecording

onRecordingUpdated

RoomSession.listen({ onRecordingUpdated: Callback })

Emitted when a recording in the room is updated. Your event handler will be called with an instance of the RoomSessionRecording object.

Parameters

NameType
recordingRoomSessionRecording

onRecordingEnded

RoomSession.listen({ onRecordingEnded: Callback })

Emitted when a recording in the room ends. Your event handler will be called with an instance of the RoomSessionRecording object.

Parameters

NameType
recordingRoomSessionRecording

onStreamEnded

RoomSession.listen({ onStreamEnded: Callback })

Emitted when a stream in the room ends. Your event handler will be called with an instance of the RoomSessionStream object.

Parameters

NameType
streamRoomSessionStream

onStreamStarted

RoomSession.listen({ onStreamStarted: Callback })

Emitted when a stream starts in the room. Your event handler will be called with an instance of the RoomSessionStream object.

Parameters

NameType
streamRoomSessionStream

Alias Types

VideoPositions

VideoPositions: [ key: string]: VideoPosition

An object whose keys represent member IDs, and values the layout position to assign. Instead of a member ID, in some contexts you can use the special keyword self if you don't know yet the ID of the member which is going to be created.

NameTypeDescription
autostringThe position of the member in the layout is determined automatically.
reserved-positionNumberstringThe reserved position in the layout.
(e.g. reserved-3)
standard -positionNumberstringThe reserved position in the layout.
(e.g. reserved-3)
off-canvasstringAssign the member off-canvas, outside the layout.