Skip to main content

Callback for Friend Module (FriendBaseResultObserver)

If you are using Unreal Engine, please refer to Unreal Engine SDK's FriendBaseResultObserver.

Register the callback for the Player Network SDK Friends module; the game needs to register the callback for processing.For more information about the callback data structure, please refer to BaseResult.

note

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

Function definition

// Add INTLBaseResult callback
public static void AddFriendBaseResultObserver(OnINTLResultHandler<INTLBaseResult> callback);
// Remove INTLBaseResult callback
public static void RemoveFriendBaseResultObserver(OnINTLResultHandler<INTLBaseResult> callback);

Code sample

// Add callback
public void AddFriendObserver()
{
INTLAPI.AddFriendBaseResultObserver(OnFriendBaseEvent);
}

// Remove callback
public void RemoveFriendObserver()
{
INTLAPI.RemoveFriendBaseResultObserver(OnFriendBaseEvent);
}

// Callback handler for INTLBaseResult
public void OnFriendBaseEvent(INTLBaseResult ret)
{
Debug.Log($"MethodID: {ret.MethodId}");

string methodTag = "";

if (ret.MethodId == (int)INTLMethodID.INTL_FRIEND_SHARE)
{
methodTag = "Share";
}
else if (ret.MethodId == (int)INTLMethodID.INTL_FRIEND_SEND_MESSAGE)
{
methodTag = "SendMessage";
}
ShowLogInNewLine(methodTag + Tools.Instance.GetRetString(ret));
}