跳到主要内容

GUABaseResultObservers

[Player Network SDK 和 MSDK 共有] 注册登录模块的回调,游戏需要对回调函数进行处理。更多关于回调数据结构,可以查看下面的数据结构 GUABaseResult

注意

强烈建议游戏在应用启动函数中进行注册。

函数定义

回调事件用于处理的方法列表

回调事件Common[仅限 Player Network SDK][仅限 MSD]
LoginBaseResultEventsLogout,
ResetGuest
ModifyLegalDocumentsAcceptedVersion,
Unbind,
CancelAccountDeletion
CheckUniversalLink,
ChannelPermissionAuth
event OnResultHandler<GUABaseResult> LoginBaseResultEvents;

代码示例

// 增加回调
UnionAdapterAPI.GetAccountService().LoginBaseResultEvents += OnLoginBaseResultEvent;

// 移除回调
UnionAdapterAPI.GetAccountService().LoginBaseResultEvents -= OnLoginBaseResultEvent;

// LoginBaseResultEvents 的回调处理
public void OnLoginBaseResultEvent(GUABaseResult baseRet)
{
Debug.Log("OnLoginBaseResultEvent in Login");
string methodTag = "";
if (baseRet.MethodId == (int)GUAMethodID.GUA_ACCOUNT_LOGOUT)
{
methodTag = "Logout";
}
else if (baseRet.MethodId == (int)GUAMethodID.GUA_ACCOUNT_WAKEUP) // [仅限 MSD]
{
handleDiifAccount(baseRet);
}
else if (baseRet.MethodId == (int)GUAMethodID.GUA_ACCOUNT_UNBIND) // [仅限 Player Network SDK]
{
methodTag = "Unbind";
}
else if (baseRet.MethodId == (int)GUAMethodID.GUA_ACCOUNT_MODIFY_LEGAL_DOCUMENTS) // [仅限 Player Network SDK]
{
methodTag = "ModifyLegalDocument";
}
Debug.Log(methodTag + baseRet);
}

/// <summary>
/// 处理异账号
/// </summary>
/// <param name="baseRet">Base ret.</param>
private void handleDiifAccount(GUABaseResult baseRet)
{
string methodTag = "WAKEUP";
switch (baseRet.RetCode)
{
case GUAErrorCode.SUCCESS:
{ // 本地原有票据有效,使用原有票据登录
Debug.Log(methodTag + "Use the original ticket to log in, the game does not need to be processed");
break;
}
case GUAErrorCode.LOGIN_ACCOUNT_REFRESH:
{ // 新旧 openid 相同,票据不同。刷新登录票据
Debug.Log(methodTag + "The old and new openid is the same, but the ticket is different. Refresh the login ticket, the game does not need to process");
break;
}
case GUAErrorCode.LOGIN_URL_USER_LOGIN:
{// 本地无openid,拉起有票据,使用新票据登录

Debug.Log(methodTag + "The old and new openid is the same, but the ticket is different. Refresh the login ticket, the game does not need to process");
break;
}
case GUAErrorCode.LOGIN_NEED_SELECT_ACCOUNT:
{
Debug.Log(methodTag + "Need select account")
break;
}
case GUAErrorCode.LOGIN_NEED_LOGIN:
{
Debug.Log(methodTag + "Tickets are invalid, enter the login page");
}
break;
default:
break;
}
}