Skip to main content

Login module callback (AuthResultObserver)

If you are using Unreal Engine, refer to the Unreal Engine SDK's AuthResultObserver.

Register the callback for the Player Network SDK login module; the game needs to handle the callback accordingly.For more about the callback data structure, refer to AuthResult.

note

It is strongly recommended that games register during the application start-up function.

Function definition

// Add INTLAuthResult callback for handling Login, AutoLogin, QueryUserInfo,
// ResetGuest, Bind, QueryCanBind callbacks
public static void AddAuthResultObserver(OnINTLResultHandler<INTLAuthResult> callback);

// Remove INTLAuthResult callback
public static void RemoveAuthResultObserver(OnINTLResultHandler<INTLAuthResult> callback);

Code sample

// Add callback
public void AddAuthObserver()
{
INTLAPI.AddAuthResultObserver(OnAuthResultEvent);
}

// Remove callback
public void RemoveAuthObserver()
{
INTLAPI.RemoveAuthResultObserver(OnAuthResultEvent);
}

// Process the callback for AuthResultObserver
private void OnAuthResultEvent(INTLAuthResult AuthResult)
{
switch (AuthResult.MethodId)
{
// LI PASS third-party/LI login enters the game
case (int)INTLMethodID.LI_LOGIN_ENTER_GAME:
if(AuthResult.RetCode == (int)ERROR_CODE.SUCCESS) {
Debug.Log("LI PASS Login success");
} else {
Debug.Log("LI PASS Login failed, ret_code = " + AuthResult.RetCode + ", ret_msg = " + AuthResult.RetMsg);
LevelInfinite.OpenLoginPanel();
}
break;
// LI PASS auto-login enters the game
case (int)INTLMethodID.LI_AUTOLOGIN_ENTER_GAME:
if(AuthResult.RetCode == (int)ERROR_CODE.SUCCESS) {
Debug.Log("LI PASS Autologin success");
} else {
Debug.Log("LI PASS Autologin failed, ret_code = " + AuthResult.RetCode + ", ret_msg = " + AuthResult.RetMsg);
LevelInfinite.OpenLoginPanel();
}
break;
default:
break;
}
}