promote

View as Markdown

promote

  • promote(params): Promise<void>

Promotes a participant from “audience” to “member”. See demote.

Parameters

params
objectRequired

Object containing the parameters of the method.

memberId
stringRequired

ID of the audience participant to promote.

joinAudioMuted
boolean

Force the member’s audio to be muted right after the promotion.

joinVideoMuted
boolean

Force the member’s video to be muted right after the promotion.

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

Specifies the media that the client will be allowed to send. A member participant can always receive all media.

meta
Record<string, unknown>

Metadata to assign to the member.

permissions
string[]

List of permissions to grant when the Audience participant will become a Member.

Returns

Promise<void>

Example

In this example, we demote a member to audience as soon as they join the room. After 10 seconds, we promote the member back to a roomSession member. 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.id, member.name);
17 // Demote member to audience
18 console.log(`Demoting ${member.id} to audience`);
19 await roomsession.demote({
20 memberId: member.id,
21 mediaAllowed: "audio-only"
22 });
23 // wait 10 seconds then promote the member back to a roomSession member
24 setTimeout(async () => {
25 // Promote the audience participant to a member
26 console.log(`Promoting ${member.name} to member`);
27 await roomsession.promote({
28 memberId: member.id,
29 mediaAllowed: "all",
30 joinAudioMuted: true,
31 joinVideoMuted: false,
32 permissions: [
33 "room.self.audio_mute",
34 "room.self.audio_unmute",
35 "room.self.video_mute",
36 "room.self.video_unmute",
37 "room.list_available_layouts",
38 ]
39 });
40 }, 10000);
41 }
42 });
43 }
44})