Skip to main content

Callback for LBS module (LBSIPInfoResultObserver)

If you are using Unreal Engine, see Unreal Engine SDK's LBSIPInfoResultObserver.

Register the Player Network SDK LBS module callback; the game must register the callback for processing. For more details about the callback data structure, see LBSIPInfoResult.

note

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

caution
  • Due to factors of the data source, conversion between IP and regions is not 100% accurate.
  • Due to network jitter or other factors, this API may not return results.It is not recommended to use it in critical game logic.Users must also consider default adaptation strategies in case of failure.
  • The conversion relationship between IP and regions will change by default with updates in the IP library data. If business requires a fixed conversion relationship, the Player Network assistant can be contacted for separate configuration.

Function definition

// Add INTLLBSIPInfoResult callback for handling LBS callback
public static void AddLBSIPInfoResultObserver(OnINTLResultHandler<INTLLBSIPInfoResult> callback);

// Remove INTLLBSIPInfoResult callback
public static void RemoveLBSIPInfoResultObserver(OnINTLResultHandler<INTLLBSIPInfoResult> callback);

Code example

// Add callback
public void AddIPInfoObserver()
{
INTLAPI.AddLBSIPInfoResultObserver(OnIPInfoResultEvent);
}

// Remove callback
public void RemoveIPInfoObserver()
{
INTLAPI.RemoveLBSIPInfoResultObserver(OnIPInfoResultEvent);
}

// Handle callback data
private void OnIPInfoResultEvent(INTLLBSIPInfoResult ipInfoRet)
{
Debug.Log($"MethodID: {ret.MethodId}");

string methodTag = "";
if (ipInfoRet.MethodId == (int)INTLMethodID.INTL_LBS_REQUEST_IPINFO)
{
methodTag = "RequestIPInfo";
}
ShowLogInNewLine(methodTag + Tools.Instance.GetRetString(ipInfoRet));
}