Skip to main content

Callback for login module (AuthBaseResultObserver)

If you are using Unreal Engine, please refer to AuthBaseResultObserver in the Unreal Engine SDK.

Register the callback for the Player Network SDK login module. The game needs to handle the callback.For more information about the callback data structure, see BaseResult.

note

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

Function definition

// Add INTLBaseResult callback to handle Logout
public static void AddAuthBaseResultObserver(OnINTLResultHandler<INTLBaseResult> callback);

// Remove INTLBaseResult callback
public static void RemoveAuthBaseResultObserver(OnINTLResultHandler<INTLBaseResult> callback);

Code sample

// Add callback
public void AddAuthBaseObserver()
{
INTLAPI.AddAuthBaseResultObserver(OnAuthBaseResultEvent);
}

// Remove callback
public void RemoveAuthBaseObserver()
{
INTLAPI.RemoveAuthBaseResultObserver(OnAuthBaseResultEvent);
}

// Handle INTLBaseResult callback
public void OnAuthBaseResultEvent(INTLBaseResult ret)
{
Debug.Log($"MethodID: {ret.MethodId}");

string methodTag = "";
if (ret.MethodId == (int)INTLMethodID.INTL_AUTH_LOGOUT)
{
methodTag = "Logout";
}
ShowLogInNewLine(methodTag + Tools.Instance.GetRetString(ret));
}