Skip to main content

FriendResultObserver

If you were looking for the method for use with Unreal Engine, see FriendResultObserver 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 FriendResult.

note

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

Function definition

// Add the INTLFriendResult callback to process callback 
public static void AddFriendResultObserver(OnINTLResultHandler<INTLFriendResult> callback);
// Remove the INTLFriendResult callback
public static void RemoveFriendResultObserver(OnINTLResultHandler<INTLFriendResult> callback);

Code sample

// Add callbacks
public void AddFriendObserver()
{
INTLAPI.AddFriendResultObserver(OnFriendEvent);
}

// Remove callbacks
public void RemoveFriendObserver()
{
INTLAPI.RemoveFriendResultObserver(OnFriendEvent);
}

// Process the INTLFriendResult callback
public void OnFriendEvent(INTLFriendResult ret)
{
Debug.Log($"MethodID: {ret.MethodId}");

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