GUALoginResultObservers
[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 GUALoginResult.
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] |
---|---|---|---|
LoginResultEvents | Login, Bind, AutoLogin, SwitchUser, QueryUserInfo, LoginWithConfirmCode | Register, LoginWithMappedChannel, BuildMapWithLoggedinChannel, QueryLegalDocumentsAcceptedVersion, LoginWithPassword, LoginWithVerifyCode | BindUI, Check, CheckLogin, BindWithConfirmCode |
event OnResultHandler<GUALoginResult> LoginResultEvents;
The list of methods used to process the callback events.
Callback Event | Common | [Player Network SDK Only] | [MSDK Only] |
---|---|---|---|
OnLoginResultNotify | Login, Bind, AutoLogin, SwitchUser, QueryUserInfo, LoginWithConfirmCode | Register, LoginWithMappedChannel, BuildMapWithLoggedinChannel, QueryLegalDocumentsAcceptedVersion, LoginWithPassword, LoginWithVerifyCode | BindUI, Check, CheckLogin, BindWithConfirmCode |
class GUA_EXTERN GUAAccountObserver
{
public:
virtual ~GUAAccountObserver() {};
virtual void OnLoginResultNotify(const GUALoginResult &auth_result) {};
};
Code Sample
- Unity
- Unreal Engine
// Add callbacks
UnionAdapterAPI.GetAccountService().LoginResultEvents += OnLoginResultEvent;
// Remove callbacks
UnionAdapterAPI.GetAccountService().LoginResultEvents -= OnLoginResultEvent;
// LoginResultEvents callback
public void OnLoginResultEvent(GUALoginResult loginRet)
{
Debug.Log("OnLoginResultEvent");
string methodTag = "";
if (loginRet.MethodId == (int)GUAMethodID.GUA_ACCOUNT_LOGIN)
{
methodTag = "Login";
}
else if (loginRet.MethodId == (int)GUAMethodID.GUA_ACCOUNT_BIND)
{
methodTag = "Bind";
}
else if (loginRet.MethodId == (int)GUAMethodID.GUA_ACCOUNT_AUTOLOGIN)
{
methodTag = "AutoLogin";
}
else if (loginRet.MethodId == (int)GUAMethodID.GUA_ACCOUNT_SWITCH_USER)
{
methodTag = "SwitchUser";
}
else if (loginRet.MethodId == (int)GUAMethodID.GUA_ACCOUNT_QUERY_USER_INFO)
{
methodTag = "QueryUserInfo";
}
Debug.Log("OnLoginResultEvent start format json");
Debug.Log(methodTag + loginRet);
}
// 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 OnLoginResultNotify
class FGUAAccountObserver : public GUA_NAMESPACE::GUAAccountObserver {
public:
static FGUAAccountObserver Instance;
void OnLoginResultNotify(const GUA_NAMESPACE::GUALoginResult &auth_result)
{
}
}
FGUAAccountObserver FGUAAccountObserver::Instance;
//Configure the callback
GUA_NAMESPACE::GUAAccountService::SetAccountObserver(&FGUAAccountObserver::Instance);