文档

Vivox Unity SDK

Vivox Unity SDK

从游戏注销

Sign players in to Vivox with custom identifiers.
阅读时间1 分钟最后更新于 3 天前

当游戏不再希望用户登录时,它会调用
VivoxService.Instance.LogoutAsync
方法。用户注销后,Vivox SDK 不会发送或接收任何网络流量。
注意
通常仅当退出应用程序时,或是在用户可以在应用程序内登录不同帐户的情况下,当与游戏服务器断开连接时,才进行调用。
以下代码示例说明了注销过程:
using UnityEngine;using Unity.Services.Vivox;class LogoutExample : MonoBehaviour{ void LogOut() { VivoxService.Instance.LogoutAsync(); }}
为了处理连接问题导致的注销,游戏必须处理事件
VivoxService.Instance.LoggedOut
。Vivox SDK 会在与 Vivox 的连接意外丢失(例如网络连接问题)时或用户手动发起注销时发送此消息。
以下代码的示例说明如何订阅
VivoxService.Instance.LoggedOut
事件:
using 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 }}