setMeta

View as Markdown

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

meta
Record<string, unknown>Required

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.

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 the 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 onRoomEnded: async (roomSession) => {
26 console.log("Room ended", roomSession.displayName);
27 }
28});