Skip to main content

FriendBaseResultObserver

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

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

note

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

Function definition

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

Code sample

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

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

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