GUAAccountResultObservers
[Shared by Player Network SDK and MSDK] Register the callback for the custom account module. The game needs to handle the callback.For more information about the callback data structure, see GUAAccountResult.
note
It is strongly recommended that games register in the application startup function.
Function Definition
- Unity
- Unreal Engine
List of methods used to handle callback events
| Callback events | Common | [Player Network SDK only] | [MSD only] |
|---|---|---|---|
| AccountEvents | ResetPassword, QueryVerifyCodeStatus, QueryRegisterStatus, QueryReceiveEmail, ModifyAccountWithPassword, ModifyAccountWithVerifyCode | QueryCanBind, QueryBindInfo, QueryAccountProfile, ModifyProfile, QueryDataProtectionAcceptance, ModifyDataProtectionAcceptance, QueryUserNameStatus | CanBind |
event OnResultHandler<GUAAccountResult> AccountEvents;
List of methods used to handle callback events
| Callback events | Common | [Player Network SDK only] | [MSD 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 Example
- Unity
- Unreal Engine
// Add callback
UnionAdapterAPI.GetAccountService().AccountEvents += OnAccountResultEvent;
// Remove callback
UnionAdapterAPI.GetAccountService().AccountEvents -= OnAccountResultEvent;
// AccountEvents callback handling
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 in the engine layer that inherits from GUA_NAMESPACE::GUAAccountObserver
// 2. Implement callback interfaces with the same method names (e.g., OnAccountResultNotify)
class FGUAAccountObserver : public GUA_NAMESPACE::GUAAccountObserver {
public:
static FGUAAccountObserver Instance;
void OnAccountResultNotify(const GUA_NAMESPACE::GUAAccountResult &account_result)
{
}
}
FGUAAccountObserver FGUAAccountObserver::Instance;
// Set callback
GUA_NAMESPACE::GUAAccountService::SetAccountObserver(&FGUAAccountObserver::Instance);