Leave a channel

To remove a user from a channel, call VivoxService.Instance.LeaveChannelAsync(string channelName) with the name of the channel to leave. Alternatively, VivoxService.Instance.LeaveAllChannelsAsync() can be used to leave all channels the user is connected to. The disconnected channel object remains in the VivoxService.Instance.ActiveChannels list until after the disconnection is successful.

The object is immediately removed from the list if the session is completely disconnected.

Note: Disconnection is not an immediate operation and can take several seconds to complete. A ChannelLeft event will trigger when a disconnection has been completed successfully.

The following code is an example of how to perform this operation:

using UnityEngine;
using Unity.Services.Vivox;

class VivoxBasicsExample : MonoBehaviour
{
    . . .
    void LeaveChannel(string channelNameToLeave)
    {
        . . .
        VivoxService.Instance.LeaveChannelAsync(channelNameToLeave);
        . . .
    }
    . . .
}