setMemberMeta

View as Markdown

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

params
objectRequired

Object containing the parameters of the method.

memberId
string

ID of the member to affect.

meta
Record<string, unknown>Required

The metadata 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.

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 roomsession.listen({
15 onMemberJoined: async (member) => {
16 console.log("Member joined", member.name);
17 // set metadta for the member
18 await roomsession.setMemberMeta({
19 memberId: member.id,
20 meta: {
21 name: member.name,
22 foo: "bar",
23 },
24 });
25 // get member meta
26 const memberMeta = await roomsession.getMemberMeta({
27 memberId: member.id
28 });
29 console.log("Member meta", memberMeta.meta);
30 },
31 })
32 }
33})