Skip to main content

LBSIPInfoResultObserver

If you were looking for the method for use with Unreal Engine, see LBSIPInfoResultObserver for Unreal Engine SDK.

Register the callback of the Player Network SDK LBS module, the game needs to process the callback function. For more information on the callback data structure, see LBSIPInfoResult.

note

It is strongly recommended to perform registration in the startup function of the game application.

caution
  • The conversion between IPs and regions is not at 100% accuracy due to data source factors.
  • The API may fail to return results due to network jitter or other factors. It is not recommended to use it in critical game logic. Users must also consider the default adaptation policy in case of failure.
  • The conversion relationship between IP and region will change by default with the update of data in the IP database. If a fixed conversion relationship between IP and region is needed, reach out to the Player Network representative.

Function definition

// Add the INTLLBSIPInfoResult callback to process callback
public static void AddLBSIPInfoResultObserver(OnINTLResultHandler<INTLLBSIPInfoResult> callback);

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

Code sample

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

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

// Process the INTLLBSIPInfoResult callback
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));
}