从游戏注销
Sign players in to Vivox with custom identifiers.
阅读时间1 分钟最后更新于 7 个月前
当游戏不再希望用户登录时,它会调用 方法。用户注销后,Vivox SDK 不会发送或接收任何网络流量。
VivoxService.Instance.LogoutAsync以下代码示例说明了注销过程:
using UnityEngine;using Unity.Services.Vivox;class LogoutExample : MonoBehaviour{ void LogOut() { VivoxService.Instance.LogoutAsync(); }}
为了处理连接问题导致的注销,游戏必须处理事件 。Vivox SDK 会在与 Vivox 的连接意外丢失(例如网络连接问题)时或用户手动发起注销时发送此消息。
VivoxService.Instance.LoggedOut以下代码的示例说明如何订阅 事件:
VivoxService.Instance.LoggedOutusing UnityEngine;using Unity.Services.Vivox;using System.Components;class SessionPropChangeExample : MonoBehaviour{ VivoxService.Instance.LoggedOut += onVivoxLoggedOut; private void onVivoxLoggedOut() { //Vivox has logged out, and clean up should be done }}