GUAConnectResultObservers [MSDK Only]
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.[MSDK Only].
Function Definition
- Unity
- Unreal Engine
// ConnectRetEvents callback, only for Kwai channel
event OnResultHandler<GUALoginResult> ConnectRetEvents;
class GUA_EXTERN GUAConnectObserver
{
public:
virtual ~GUAConnectObserver(){};
virtual void OnConnectResultNotify(const GUALoginResult &login_result) {};
};
Code Sample
- Unity
- Unreal Engine
// Add callbacks
UnionAdapterAPI.GetAccountService().ConnectRetEvents += mLoginCallBack.OnConnectRetEvent;
// Remove callbacks
UnionAdapterAPI.GetAccountService().ConnectRetEvents -= mLoginCallBack.OnConnectRetEvent;
// ConnectRetEvents callback
public void OnConnectRetEvent(GUALoginResult loginRet)
{
Debug.Log("OnConnectRetNotify in login");
string methodTag = "";
if (loginRet.MethodId == (int)GUAMethodID.GUA_ACCOUNT_CONNECT)
{
methodTag = "Connect";
}
mCurrentTestMgr.ShowLogInNewLine(methodTag + loginRet);
}
// 1. Define an observer class that inherits from GUA_NAMESPACE::GUAccountObserver at the engine layer
// 2. Implement the callback interface with the same method name (eg: OnConnectResultNotify)
class FGUAConnectObserver : public GUA_NAMESPACE::GUAConnectObserver {
public:
static FGUAConnectObserver Instance;
void OnConnectResultNotify(const GUA_NAMESPACE::GUAConnectObserver &connect_result)
{
}
}
FGUAConnectObserver FGUAConnectObserver::Instance;
//Configure the callback
GUA_NAMESPACE::GUAAccountService::SetConnectObserver(&FGUAConnectObserver::Instance);