# 3. Group Channels and Participants Part of [[Voice Chat with Vivox]]. Back: [[2. Initialize Login and Service Lifecycle]]. Next: [[4. Mute Transmission Volume and Roster]]. > [!warning] Code not compiled in Unity > Listings follow the official quickstart and the 16.12.1 Scripting API. Not compiled or run against a live channel. ## 3.1 Echo first, then a group channel Official quickstart: after login, join an **echo** channel to test Vivox locally with `JoinEchoChannelAsync(string channelName, ChatCapability chatCapability, ChannelOptions channelOptions = null)`. You should hear yourself. Then leave it and join a real channel. - Group (2D): `JoinGroupChannelAsync(string channelName, ChatCapability chatCapability, ChannelOptions channelOptions = null)` - Positional (3D): `JoinPositionalChannelAsync(string channelName, ChatCapability chatCapability, Channel3DProperties positionalChannelProperties, ChannelOptions channelOptions = null)` Official note: **channel names must be unique across the channel types.** Do not join a group channel and an echo channel that share a name. Channels are created when the first join request is sent. `ChatCapability` in 16.12.1: `AudioOnly`, `TextAndAudio`, `TextOnly`. A classroom voice lab can start with `AudioOnly`. Add `TextAndAudio` when you actually have a text UI (the official send API is `SendChannelTextMessageAsync`; this series does not build a chat box). Leave with `LeaveChannelAsync(string channelName)` or `LeaveAllChannelsAsync()`. Events: `ChannelJoined` and `ChannelLeft` both carry the channel name (`Action<string>`). ## 3.2 Group channel wrapper ```csharp using System; using System.Threading.Tasks; using Unity.Services.Vivox; using UnityEngine; /// <summary> /// Joins and leaves one official group channel and forwards participant events. /// </summary> public sealed class VivoxGroupChannel : MonoBehaviour { public string CurrentChannel { get; private set; } = string.Empty; public event Action<VivoxParticipant> ParticipantAdded; public event Action<VivoxParticipant> ParticipantRemoved; public event Action<string> Joined; public event Action<string> Left; void OnEnable() { var v = VivoxService.Instance; v.ParticipantAddedToChannel += OnAdded; v.ParticipantRemovedFromChannel += OnRemoved; v.ChannelJoined += OnJoined; v.ChannelLeft += OnLeft; } void OnDisable() { var v = VivoxService.Instance; if (v == null) return; v.ParticipantAddedToChannel -= OnAdded; v.ParticipantRemovedFromChannel -= OnRemoved; v.ChannelJoined -= OnJoined; v.ChannelLeft -= OnLeft; } public async Task JoinGroupAsync(string channelName, ChatCapability capability = ChatCapability.AudioOnly) { if (string.IsNullOrEmpty(channelName)) throw new ArgumentException("Channel name is required.", nameof(channelName)); if (VivoxService.Instance == null || !VivoxService.Instance.IsLoggedIn) throw new InvalidOperationException("Log in to Vivox before joining a channel."); if (!string.IsNullOrEmpty(CurrentChannel) && CurrentChannel != channelName) await LeaveAsync(); await VivoxService.Instance.JoinGroupChannelAsync(channelName, capability); CurrentChannel = channelName; } public async Task LeaveAsync() { if (string.IsNullOrEmpty(CurrentChannel) || VivoxService.Instance == null) return; var name = CurrentChannel; await VivoxService.Instance.LeaveChannelAsync(name); CurrentChannel = string.Empty; } void OnAdded(VivoxParticipant participant) => ParticipantAdded?.Invoke(participant); void OnRemoved(VivoxParticipant participant) => ParticipantRemoved?.Invoke(participant); void OnJoined(string channelName) => Joined?.Invoke(channelName); void OnLeft(string channelName) { if (CurrentChannel == channelName) CurrentChannel = string.Empty; Left?.Invoke(channelName); } } ``` ## 3.3 Participants Official events on the service: `ParticipantAddedToChannel` and `ParticipantRemovedFromChannel` (`Action<VivoxParticipant>`). Official 16.12.1 `VivoxParticipant` properties you will actually bind: | Property | Meaning | |---|---| | `DisplayName` | The login display name | | `PlayerId` | UAS player id when Authentication is in use | | `IsSelf` | This is the local user | | `ChannelName` | Channel this participant object belongs to | | `IsInAudio` / `IsInText` | Connection flags. Official remarks: may read `false` immediately after join; subscribe to `ParticipantAudioStateChanged` / `ParticipantTextStateChanged` | | `SpeechDetected` | Audio energy crossed the speech threshold (`ParticipantSpeechDetected`) | | `AudioEnergy` | For a VU meter (`ParticipantAudioEnergyChanged`) | | `IsMuted` | Mute state (`ParticipantMuteStateChanged`) | Use **`IsInAudio`**, not `InAudio`. The unversioned quickstart snippet still says `InAudio`; the 16.12.1 Scripting API does not. `ActiveChannels` is a `ReadOnlyDictionary<string, ReadOnlyCollection<VivoxParticipant>>` keyed by the channel name you joined with. It is the official roster snapshot if you missed a live event. ## 3.4 Why the classroom default is a group channel A colocated Quest classroom ([[Multi-Headset Quest Classroom Sessions]]) already shares a real room. Students standing two metres apart should still hear the teacher clearly. A **positional** channel, with `Channel3DProperties` and `Set3DPosition`, is for virtual-world distance, not for a seminar table. Use a **group** channel keyed to the session (part 5). If you later add a large social lobby where distance should matter, that is a *different* channel name (unique across types) and a deliberate 3D join — not a surprise fade on the teacher. Next: [[4. Mute Transmission Volume and Roster]].