updateMeta

View as Markdown

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

meta
Record<string, unknown>Required

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.

1import { SignalWire } from "@signalwire/realtime-api";
2
3// Initialize the SignalWire client
4const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" });
5
6// Access video client from the main client
7const videoClient = client.video;
8
9// Setup listener for when a room starts
10await videoClient.listen({
11 onRoomStarted: async (roomSession) => {
12 console.log("Room started", roomSession.displayName);
13
14 // Set the room meta
15 console.log("Setting room meta");
16 await roomSession.setMeta({
17 "foo": "bar",
18 "roomName": roomSession.displayName
19 });
20
21 // Get the room meta
22 let roomMeta = await roomSession.getMeta()
23 console.log("Room meta", roomMeta);
24
25 // update the room meta after 5 seconds
26 setTimeout(async () => {
27 console.log("Updating room meta");
28 await roomSession.setMeta({
29 "foo": "bar",
30 "roomName": roomSession.displayName,
31 "updated": true
32 });
33 console.log("Room meta Updated:", await roomSession.getMeta());
34 }, 5000);
35 },
36 onRoomEnded: async (roomSession) => {
37 console.log("Room ended", roomSession.displayName);
38 }
39});