demote

View as Markdown

demote

  • demote(params): Promise<void>

Demotes a participant from “member” to “audience”. See promote.

Parameters

params
objectRequired

Object containing the parameters of the method.

memberId
stringRequired

ID of the member to affect.

mediaAllowed
"all" | "audio-only" | "video-only"

Specifies the media that the client will be allowed to receive. An audience participant cannot send any media.

Returns

Promise<void>

Example

In this example, we demote a member to audience as soon as they join the 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 await roomsession.listen({
14 // Listen for when a member is updated
15 onMemberJoined: async (member) => {
16 console.log("Member joined", member.name);
17 // Demote member to audience
18 console.log(`Demoting ${member.name} to audience`);
19 roomsession.demote({
20 memberId: member.id,
21 mediaAllowed: "audio-only"
22 });
23 }
24 });
25 }
26})