Skip to main content

ChannelWebRtcClient

ChannelWebRtcClient = TypedEventEmitter<ChannelWebRtcEvents> & object

Service client for monitoring and moderating voice channel participants. Provides methods to list active participants, kick users from voice, and apply server-side mute or deafen states.

This client does not provide access to audio content. Apps and bots can observe participation events and enforce policies based on observable state, but cannot listen to or broadcast audio.

Access this client via rootServer.community.channelWebRtcs.

Type Declaration​

kick()​

kick(request: ChannelWebRtcKickRequest): Promise<void>

Removes a participant from a voice channel. The user can rejoin unless other restrictions apply.

Parameters​

ParameterTypeDescription
requestChannelWebRtcKickRequestIdentifies the channel and user to kick.

Returns​

Promise<void>

A promise that resolves when the kick completes.

Throws​

RootApiException with errorCode set to NoPermissionToKick if missing required permissions, or NotFound if the user is not in the voice channel.

Example​

import {
ChannelWebRtcKickRequest,
ChannelGuid,
UserGuid,
rootServer,
} from "@rootsdk/server-app";

export async function kickExample(
channelId: ChannelGuid,
userId?: UserGuid,
): Promise<void> {
try {
// Set up the request
const request: ChannelWebRtcKickRequest = {
channelId: channelId,
userId: userId,
};

// Call the API
await rootServer.community.channelWebRtcs.kick(request);
} catch (error) {
// Detect error
throw error;
}
}

Authorization​

Declare the following permissions in your manifest:

"permissions": {
"channel": {
"voiceKick": true
}
}

The community must also create channel access rules that give your code any needed visibility but don't deny these permissions via an overlay:

  • voiceKick on the channel

list()​

list(request: ChannelWebRtcListRequest): Promise<ChannelWebRtcListResponse>

Lists all participants currently in a voice channel. If no voice session is active, returns an empty array rather than throwing an error.

Parameters​

ParameterTypeDescription
requestChannelWebRtcListRequestIdentifies the voice channel to query.

Returns​

Promise<ChannelWebRtcListResponse>

A promise that resolves to a ChannelWebRtcListResponse containing the session creation time and array of participants. When no voice session is active, members is an empty array.

Throws​

RootApiException with errorCode set to NoPermissionToRead if missing required permissions.

Example​

import {
ChannelWebRtcListRequest,
ChannelWebRtcListResponse,
ChannelGuid,
rootServer,
} from "@rootsdk/server-app";

export async function listExample(
channelId: ChannelGuid,
): Promise<ChannelWebRtcListResponse> {
try {
// Set up the request
const request: ChannelWebRtcListRequest = {
channelId: channelId,
};

// Call the API
const response: ChannelWebRtcListResponse =
await rootServer.community.channelWebRtcs.list(request);

return response;
} catch (error) {
// Detect error
throw error;
}
}

setMuteAndDeafenOther()​

setMuteAndDeafenOther(request: ChannelWebRtcSetMuteAndDeafenOtherRequest): Promise<void>

Applies server-side mute or deafen state to a participant. Server mutes cannot be overridden by the user until removed by an app or moderator.

Parameters​

ParameterTypeDescription
requestChannelWebRtcSetMuteAndDeafenOtherRequestIdentifies the channel, user, and desired mute/deafen state.

Returns​

Promise<void>

A promise that resolves when the state change completes.

Throws​

RootApiException with errorCode set to NoPermissionToMute if missing required permissions, or NotFound if the user is not in the voice channel.

Example​

import {
ChannelWebRtcSetMuteAndDeafenOtherRequest,
ChannelGuid,
UserGuid,
rootServer,
} from "@rootsdk/server-app";

export async function setMuteAndDeafenOtherExample(
channelId: ChannelGuid,
userId: UserGuid,
isMuted?: boolean,
isDeafened?: boolean,
): Promise<void> {
try {
// Set up the request
const request: ChannelWebRtcSetMuteAndDeafenOtherRequest = {
channelId: channelId,
userId: userId,
isMuted: isMuted,
isDeafened: isDeafened,
};

// Call the API
await rootServer.community.channelWebRtcs.setMuteAndDeafenOther(request);
} catch (error) {
// Detect error
throw error;
}
}

Authorization​

Depending on your usage, you may also need to declare:

  • voiceMuteOther if setting isMuted
  • voiceDeafenOther if setting isDeafened