removeMember

View as Markdown

removeMember

  • removeMember(params): Promise<void>

Removes a specific participant from the room.

Parameters

params
objectRequired

Object containing the parameters of the method.

memberId
stringRequired

ID of the member to remove.

Returns

Promise<void>

Example

In this example, we wait for a room to start and then remove the second member that joins the 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 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 // listen for when new participants join the room
15 roomsession.listen({
16 onMemberJoined: async (member) => {
17 console.log("Member joined", member.name);
18
19 // remove the member from the room after 5 seconds
20
21 setTimeout(async () => {
22 console.log("Removing member", member.name);
23 roomsession.removeMember({
24 memberId: member.id,
25 });
26 }, 5000);
27 },
28 });
29 }
30});