unlock

View as Markdown

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.

1import { SignalWire } from "@signalwire/realtime-api";
2
3const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" })
4
5const videoClient = client.video;
6
7// Setup listener for when a room starts
8await videoClient.listen({
9 onRoomStarted: async (roomsession) => {
10 // Lock the room
11 console.log('Locking room');
12 await roomsession.lock();
13
14 // unlock the room after 20 seconds
15
16 setTimeout(async () => {
17 console.log('Unlocking room');
18 await roomsession.unlock();
19 }, 20000);
20
21 roomsession.listen({
22 onMemberJoined: async (member) => {
23 console.log('Member joined', member.name);
24 },
25 onMemberLeft: async (member) => {
26 console.log('Member left', member.name);
27 },
28 })
29 }
30 })