Voice: participants property

Available since @irtio/client 5.0Browsers

The participants read-only property of the Voice interface is the set of the other players on the voice server, whether or not the room has this player hear them.

Value

A ReadonlySet<string> of player IDs, which doesn’t include this player. It’s empty while voice is down.

Description

participants is everyone a voice chat list should show. A player in the room who hasn’t joined voice, or whose voice dropped, isn’t in it. The participants event fires with the new set each time a player joins or leaves voice.

Who this player hears is the room’s decision, in RoomClient.peers, so a participant may be one this player doesn’t hear.

Examples

Marking who is on voice

A lobby list marks each player in the room who is on voice.

// on-voice.ts
import type { RoomClient } from "@irtio/client";
import type { Voice } from "@irtio/client/voice";

export function voiceList(room: RoomClient, voice: Voice): string[] {
  return [...room.presence].map((p) => (voice.participants.has(p.player) || p.player === room.player ? `${p.name} (voice)` : p.name));
}

This player isn’t in participants, so the list checks it separately.

See also

Runtime availability

Browsers
participants5.0