GUAAccountResultObservers
[Player Network SDK 和 MSDK 共有] 注册自建账号模块的回调,游戏需要对回调函数进行处理。更多关于回调数据结构,可以查看 GUAAccountResult。
注意
强烈建议游戏在应用启动函数中进行注册。
函数定义
- Unity
- Unreal Engine
回调事件用于处理的方法列表
回调事件 | Common | [仅限 Player Network SDK] | [仅限 MSD] |
---|---|---|---|
AccountEvents | ResetPassword, QueryVerifyCodeStatus, QueryRegisterStatus, QueryReceiveEmail, ModifyAccountWithPassword, ModifyAccountWithVerifyCode | QueryCanBind, QueryBindInfo, QueryAccountProfile, ModifyProfile, QueryDataProtectionAcceptance, ModifyDataProtectionAcceptance, QueryUserNameStatus | CanBind |
event OnResultHandler<GUAAccountResult> AccountEvents;
回调事件用于处理的方法列表
回调事件 | Common | [仅限 Player Network SDK] | [仅限 MSD] |
---|---|---|---|
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) {};
};
代码示例
- Unity
- Unreal Engine
// 增加回调
UnionAdapterAPI.GetAccountService().AccountEvents += OnAccountResultEvent;
// 移除回调
UnionAdapterAPI.GetAccountService().AccountEvents -= OnAccountResultEvent;
// AccountEvents 的回调处理
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.在引擎层定义继承自 GUA_NAMESPACE::GUAAccountObserver 的观察者类
// 2.实现方法名一样的回调接口(如:OnAccountResultNotify)
class FGUAAccountObserver : public GUA_NAMESPACE::GUAAccountObserver {
public:
static FGUAAccountObserver Instance;
void OnAccountResultNotify(const GUA_NAMESPACE::GUAAccountResult &account_result)
{
}
}
FGUAAccountObserver FGUAAccountObserver::Instance;
// 设置回调
GUA_NAMESPACE::GUAAccountService::SetAccountObserver(&FGUAAccountObserver::Instance);