GUAConnectResultObservers [MSDK Only]
Register the login module callback; the game needs to handle the callback.For more information on the callback data structure, see the following data structure: GUALoginResult.
note
[MSDK Only] It is strongly recommended that the game registers the callback in the application’s startup function.
Function Definition
- Unity
- Unreal Engine
// ConnectRetEvents callback, Kwai channel only
event OnResultHandler<GUALoginResult> ConnectRetEvents;
class GUA_EXTERN GUAConnectObserver
{
public:
virtual ~GUAConnectObserver(){};
virtual void OnConnectResultNotify(const GUALoginResult &login_result) {};
};
Code Example
- Unity
- Unreal Engine
// Add callback
UnionAdapterAPI.GetAccountService().ConnectRetEvents += mLoginCallBack.OnConnectRetEvent;
// Remove callback
UnionAdapterAPI.GetAccountService().ConnectRetEvents -= mLoginCallBack.OnConnectRetEvent;
// Handling for 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 in the engine layer that inherits from GUA_NAMESPACE::GUAccountObserver
// 2. Implement callback interfaces with the same method names (e.g., OnConnectResultNotify)
class FGUAConnectObserver : public GUA_NAMESPACE::GUAConnectObserver {
public:
static FGUAConnectObserver Instance;
void OnConnectResultNotify(const GUA_NAMESPACE::GUAConnectObserver &connect_result)
{
}
}
FGUAConnectObserver FGUAConnectObserver::Instance;
// Set callback
GUA_NAMESPACE::GUAAccountService::SetConnectObserver(&FGUAConnectObserver::Instance);