文档

支持

Vivox Unity SDK

Vivox Unity SDK

离开频道

How to remove a player from a Vivox channel and disconnect from communication.
阅读时间1 分钟最后更新于 13 天前

若要从频道中移除用户,请调用
VivoxService.Instance.LeaveChannelAsync(string channelName)
并指定要离开的频道的名称。或者,也可使用
VivoxService.Instance.LeaveAllChannelsAsync()
表示离开用户连接的所有频道。已断开连接的频道对象仍位于
VivoxService.Instance.ActiveChannels
列表中,直到成功断开连接之后。
如果会话完全断开连接,则会立即从列表中移除对象。 以下代码示例说明如何执行此操作:
using UnityEngine;using Unity.Services.Vivox;class VivoxBasicsExample : MonoBehaviour{ . . . void LeaveChannel(string channelNameToLeave) { . . . VivoxService.Instance.LeaveChannelAsync(channelNameToLeave); . . . } . . .}