GUAAccountResultObservers
[MSDK and Player Network SDK] Registers the callback of the custom account module, the game needs to process the callback function. For more information on the callback data structure, see GUAAccountResult.
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] |
---|---|---|---|
AccountEvents | ResetPassword, QueryVerifyCodeStatus, QueryRegisterStatus, QueryReceiveEmail, ModifyAccountWithPassword, ModifyAccountWithVerifyCode | QueryCanBind, QueryBindInfo, QueryAccountProfile, ModifyProfile, QueryDataProtectionAcceptance, ModifyDataProtectionAcceptance, QueryUserNameStatus | CanBind |
event OnResultHandler<GUAAccountResult> AccountEvents;
The list of methods used to process the callback events.
Callback Event | Common | [Player Network SDK Only] | [MSDK Only] |
---|---|---|---|
OnAccountResultNotify | ResetPassword, QueryVerifyCodeStatus, QueryRegisterStatus, QueryReceiveEmail, ModifyAccountWithPassword, ModifyAccountWithVerifyCode | QueryCanBind, QueryBindInfo, QueryAccountProfile, ModifyProfile, QueryDataProtectionAcceptance, ModifyDataProtectionAcceptance, QueryUserNameStatus | CanBind |
class GUA_EXTERN GUAAccountObserver
{
public:
virtual ~GUAAccountObserver() {};
virtual void OnAccountResultNotify(const GUAAccountResult &account_result) {};
};
Code Sample
- Unity
- Unreal Engine
// Add callbacks
UnionAdapterAPI.GetAccountService().AccountEvents += OnAccountResultEvent;
// Remove callbacks
UnionAdapterAPI.GetAccountService().AccountEvents -= OnAccountResultEvent;
// AccountEvents callback
public void OnAccountResultEvent(GUAAccountResult accountRet)
{
Debug.Log("OnAuthAccountResultEvent in Login");
string methodTag = "";
if (accountRet.MethodId == (int)GUAMethodID.GUA_ACCOUNT_RESET_PASSWORD)
{
methodTag = "ResetPassword";
}
else if (accountRet.MethodId == (int)GUAMethodID.GUA_ACCOUNT_MODIFY_ACCOUNT)
{
methodTag = "ModifyAccount";
}
else if (accountRet.MethodId == (int)GUAMethodID.GUA_ACCOUNT_QUERY_REGISTER_STATUS)
{
methodTag = "QueryRegisterStatus";
}
else if (accountRet.MethodId == (int)GUAMethodID.GUA_ACCOUNT_QUERY_VERIFY_CODE_STATUS)
{
methodTag = "QueryVerifyCodeStatus";
}
else if (accountRet.MethodId == (int)GUAMethodID.GUA_ACCOUNT_QUERY_IS_RECEIVE_EMAIL)
{
methodTag = "QueryIsReceiveEmail";
}
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 OnAccountResultNotify
class FGUAAccountObserver : public GUA_NAMESPACE::GUAAccountObserver {
public:
static FGUAAccountObserver Instance;
void OnAccountResultNotify(const GUA_NAMESPACE::GUAAccountResult &account_result)
{
}
}
FGUAAccountObserver FGUAAccountObserver::Instance;
//Configure the callback
GUA_NAMESPACE::GUAAccountService::SetAccountObserver(&FGUAAccountObserver::Instance);