getMembers

View as Markdown

getMembers

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.

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 // get all members in the room
14 const members = await roomsession.getMembers();
15
16 // log the members names
17 members.members.forEach((member) => console.log(member.name));
18 }
19})