GUABaseResultObservers
[MSDK and Player Network SDK] Registers the callback of the Auth module, the game needs to process the callback function. For more information on the callback data structure, see GUABaseResult.
note
It is strongly recommended to perform registration in the startup function of the game application.
Function Definition
- Unity
- Unreal Engine
The list of methods used to process the callback events.
Callback Event | Common | [Player Network SDK Only] | [MSDK Only] |
---|---|---|---|
LoginBaseResultEvents | Logout, ResetGuest | ModifyLegalDocumentsAcceptedVersion, Unlink, CancelAccountDeletion | CheckUniversalLink, ChannelPermissionAuth |
event OnResultHandler<GUABaseResult> LoginBaseResultEvents;
The list of methods used to process the callback events.
Callback Event | Common | [Player Network SDK Only] | [MSDK Only] |
---|---|---|---|
OnBaseResultNotify | Logout, ResetGuest | ModifyLegalDocumentsAcceptedVersion, Unlink, CancelAccountDeletion | CheckUniversalLink, ChannelPermissionAuth |
class GUA_EXTERN GUAAccountObserver
{
public:
virtual ~GUAAccountObserver() {};
virtual void OnBaseResultNotify(const GUABaseResult &base_result) {};
};
Code Sample
- Unity
- Unreal Engine
// Add callbacks
UnionAdapterAPI.GetAccountService().LoginBaseResultEvents += OnLoginBaseResultEvent;
// Remove callbacks
UnionAdapterAPI.GetAccountService().LoginBaseResultEvents -= OnLoginBaseResultEvent;
// LoginBaseResultEvents callback
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) // [MSDK Only]
{
handleDiifAccount(baseRet);
}
else if (baseRet.MethodId == (int)GUAMethodID.GUA_ACCOUNT_UNBIND) // [Player Network SDK Only]
{
methodTag = "Unbind";
}
else if (baseRet.MethodId == (int)GUAMethodID.GUA_ACCOUNT_MODIFY_LEGAL_DOCUMENTS) // [Player Network SDK Only]
{
methodTag = "ModifyLegalDocument";
}
Debug.Log(methodTag + baseRet);
}
/// <summary>
/// Handle abnormal account
/// </summary>
/// <param name="baseRet">Base ret.</param>
private void handleDiifAccount(GUABaseResult baseRet)
{
string methodTag = "WAKEUP";
switch (baseRet.RetCode)
{
case GUAErrorCode.SUCCESS:
{ // The original local ticket is valid, use the original ticket to log in
Debug.Log(methodTag + "Use the original ticket to log in, the game does not need to be processed");
break;
}
case GUAErrorCode.LOGIN_ACCOUNT_REFRESH:
{ // The old and new openid is the same, but the ticket is different. Refresh the login ticket
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:
{// No local openid, use a new ticket to log in
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;
}
}
// 1. Define an observer class that inherits from GUA_NAMESPACE::GUAAccountObserver at the engine level.
// 2. Implement a callback interface with the same method name such as OnBaseResultNotify
class FGUAAccountObserver : public GUA_NAMESPACE::GUAAccountObserver {
public:
static FGUAAccountObserver Instance;
void OnBaseResultNotify(const GUA_NAMESPACE::GUABaseResult &base_result)
{
}
}
FGUAAccountObserver FGUAAccountObserver::Instance;
//Configure the callback
GUA_NAMESPACE::GUAAccountService::SetAccountObserver(&FGUAAccountObserver::Instance);