跳到主要内容

Client Friend API Reference

The Friends service allows developers to manage the player's friend list. The player can invite friends to join a party for matchmaking or to chat.

API List

APIDescription
GetFriendListGet my friend list.
AddFriendAdd the player to my friend list. If the peer player is online, he will receive an OnAddFriendRequest event. If the peer player is not online, he can call GetReceivedFriendRequests API when he goes online later to know that someone wants to add him as a friend. Only after the peer player accepts your friend request can the two of you become friends with each other.
RemoveFriendRemove the player from my friend list. If the peer player is online, he will receive an OnFriendRemoved event. If the peer player is not online, he will not receive an OnFriendRemoved event even when he is online, but the friend list will be updated. Note: Only the peer player can receive the OnFriendRemoved event, the API caller(you) can check the callback result for the operation succeeded or not.
GetReceivedFriendRequestsGet the list of received friend requests. These friend requests are from the players who want to add me as a friend.
GetSentFriendRequestsGet the list of sent friend requests. These friend requests are from me because I want to add some players as a friend.
AcceptFriendRequestAccept the player's request, after that, the two of us become friends with each other. If the peer player is online, he will receive an OnAddFriendResponse event. If the peer player is not online, he will not receive the OnAddFriendResponse event even if he goes online later, but the friend list will be updated. Note: Only the peer player can receive the OnAddFriendResponse event, the API caller(you) can check the callback result for the operation succeeded or not.
RejectFriendRequestReject the player's request.
DelSentFriendRequestDelete the friend request I sent to other player. Affects the result returned when calling the GetSentFriendRequests API in the future.
BatchAddFriendAdd players to my friend list. (max 50 players)
SearchPlayersSearch for players.
SearchPlayersWithFilterSearch for players with filter.
GetRecentPlayersGet recent players. Players on the blocklist will be filtered out. Return up to 20 recent players who have interacted with the current player.
GetRecommendedPlayersGet recommended players. Friends and blocklisted players will be filtered out.
GetPotentialFriendsGet a list of players who may be your friends. Friends and blocklisted players will be filtered out. And the result will be ordered by the mutual friend count descending.
SetFriendRemarkSet remark to your friend, for example, "Tommy, a humorous man, met in the battle.", Max remark length: 32 characters.
SubscribeFriendPresenceSubscribe to the presence of all friends. You will be notified of presence changes from your friends.
UnsubscribeFriendPresenceUnsubscribe friend presence.
GetMyFriendsLimitQuery the maximum limit of friends you can have.
GetMutualFriendsCountGet mutual friends count between this player and target players.

Event List

EventDescription
OnAddFriendRequestThe event will be triggered when receive a request to add friend.
OnAddFriendResponseThe event will be triggered when your add-friend request was accepted by player.
OnFriendRemovedThe event will be triggered when someone has remove you from his/her friend list.
OnBadgeNumOfFriendReqThe event will be triggered when the player login PGOS or the list of friend requests received changes.
OnFriendPresenceChangedThe event will be triggered when the presence of a friend changed. The premise is that you must first subscribe to the friend presence.

API Details

GetFriendList

Get my friend list.

/// <summary>Get my friend list.</summary>
public void GetFriendList(FriendDelegate0 callback);

Parameters:

ParamTypeDescription
callbackFriendDelegate0

Return: void

AddFriend

Add the player to my friend list. If the peer player is online, he will receive an OnAddFriendRequest event. If the peer player is not online, he can call GetReceivedFriendRequests API when he goes online later to know that someone wants to add him as a friend. Only after the peer player accepts your friend request can the two of you become friends with each other.

/// <summary>
/// Add the player to my friend list.
/// If the peer player is online, he will receive an OnAddFriendRequest event.
/// If the peer player is not online, he can call GetReceivedFriendRequests API when he goes online later to know that someone wants to add him as a friend.
/// Only after the peer player accepts your friend request can the two of you become friends with each other.
/// </summary>
/// <param name="pgos_params">Request struct for add friend</param>
public void AddFriend(AddFriendParams pgos_params, FriendDelegate1 callback);

Parameters:

ParamTypeDescription
pgos_paramsAddFriendParamsRequest struct for add friend
callbackFriendDelegate1

Return: void

RemoveFriend

Remove the player from my friend list. If the peer player is online, he will receive an OnFriendRemoved event. If the peer player is not online, he will not receive an OnFriendRemoved event even when he is online, but the friend list will be updated. Note: Only the peer player can receive the OnFriendRemoved event, the API caller(you) can check the callback result for the operation succeeded or not.

/// <summary>
/// Remove the player from my friend list.
/// If the peer player is online, he will receive an OnFriendRemoved event.
/// If the peer player is not online, he will not receive an OnFriendRemoved event even when he is online, but the friend list will be updated.
/// Note: Only the peer player can receive the OnFriendRemoved event, the API caller(you) can check the callback result for the operation succeeded or not.
/// </summary>
/// <param name="player_id">The player id to remove</param>
public void RemoveFriend(string player_id, FriendDelegate1 callback);

Parameters:

ParamTypeDescription
player_idstringThe player id to remove
callbackFriendDelegate1

Return: void

GetReceivedFriendRequests

Get the list of received friend requests. These friend requests are from the players who want to add me as a friend.

/// <summary>
/// Get the list of received friend requests.
/// These friend requests are from the players who want to add me as a friend.
/// </summary>
public void GetReceivedFriendRequests(FriendDelegate2 callback);

Parameters:

ParamTypeDescription
callbackFriendDelegate2

Return: void

GetSentFriendRequests

Get the list of sent friend requests. These friend requests are from me because I want to add some players as a friend.

/// <summary>
/// Get the list of sent friend requests.
/// These friend requests are from me because I want to add some players as a friend.
/// </summary>
public void GetSentFriendRequests(FriendDelegate2 callback);

Parameters:

ParamTypeDescription
callbackFriendDelegate2

Return: void

AcceptFriendRequest

Accept the player's request, after that, the two of us become friends with each other. If the peer player is online, he will receive an OnAddFriendResponse event. If the peer player is not online, he will not receive the OnAddFriendResponse event even if he goes online later, but the friend list will be updated. Note: Only the peer player can receive the OnAddFriendResponse event, the API caller(you) can check the callback result for the operation succeeded or not.

/// <summary>
/// Accept the player's request, after that, the two of us become friends with each other.
/// If the peer player is online, he will receive an OnAddFriendResponse event.
/// If the peer player is not online, he will not receive the OnAddFriendResponse event even if he goes online later, but the friend list will be updated.
/// Note: Only the peer player can receive the OnAddFriendResponse event, the API caller(you) can check the callback result for the operation succeeded or not.
/// </summary>
/// <param name="player_id">The player id who sent the add-friend request</param>
public void AcceptFriendRequest(string player_id, FriendDelegate3 callback);

Parameters:

ParamTypeDescription
player_idstringThe player id who sent the add-friend request
callbackFriendDelegate3

Return: void

RejectFriendRequest

Reject the player's request.

/// <summary>Reject the player's request.</summary>
/// <param name="player_id">The player id who sent the add-friend request</param>
public void RejectFriendRequest(string player_id, FriendDelegate1 callback);

Parameters:

ParamTypeDescription
player_idstringThe player id who sent the add-friend request
callbackFriendDelegate1

Return: void

DelSentFriendRequest

Delete the friend request I sent to other player. Affects the result returned when calling the GetSentFriendRequests API in the future.

/// <summary>
/// Delete the friend request I sent to other player.
/// Affects the result returned when calling the GetSentFriendRequests API in the future.
/// </summary>
/// <param name="player_id">The id of other player</param>
public void DelSentFriendRequest(string player_id, FriendDelegate1 callback);

Parameters:

ParamTypeDescription
player_idstringThe id of other player
callbackFriendDelegate1

Return: void

BatchAddFriend

Add players to my friend list. (max 50 players)

/// <summary>Add players to my friend list. (max 50 players)</summary>
/// <param name="pgos_params">Request struct for batch add friend</param>
public void BatchAddFriend(BatchAddFriendParams pgos_params, FriendDelegate4 callback);

Parameters:

ParamTypeDescription
pgos_paramsBatchAddFriendParamsRequest struct for batch add friend
callbackFriendDelegate4

Return: void

SearchPlayers

Search for players.

/// <summary>Search for players.</summary>
/// <param name="pgos_params">Request struct for search players.</param>
public void SearchPlayers(SearchPlayersParams pgos_params, FriendDelegate5 callback);

Parameters:

ParamTypeDescription
pgos_paramsSearchPlayersParamsRequest struct for search players.
callbackFriendDelegate5

Return: void

SearchPlayersWithFilter

Search for players with filter.

/// <summary>Search for players with filter.</summary>
/// <param name="pgos_params">Request struct for search players with filter</param>
public void SearchPlayersWithFilter(SearchPlayersWithFilterParams pgos_params, FriendDelegate5 callback);

Parameters:

ParamTypeDescription
pgos_paramsSearchPlayersWithFilterParamsRequest struct for search players with filter
callbackFriendDelegate5

Return: void

GetRecentPlayers

Get recent players. Players on the blocklist will be filtered out. Return up to 20 recent players who have interacted with the current player.

/// <summary>Get recent players. Players on the blocklist will be filtered out. Return up to 20 recent players who have interacted with the current player.</summary>
public void GetRecentPlayers(FriendDelegate5 callback);

Parameters:

ParamTypeDescription
callbackFriendDelegate5

Return: void

GetRecommendedPlayers

Get recommended players. Friends and blocklisted players will be filtered out.

/// <summary>Get recommended players. Friends and blocklisted players will be filtered out.</summary>
/// <param name="pgos_params">Request struct for get recommended players</param>
public void GetRecommendedPlayers(GetRecommendedPlayersParams pgos_params, FriendDelegate5 callback);

Parameters:

ParamTypeDescription
pgos_paramsGetRecommendedPlayersParamsRequest struct for get recommended players
callbackFriendDelegate5

Return: void

GetPotentialFriends

Get a list of players who may be your friends. Friends and blocklisted players will be filtered out. And the result will be ordered by the mutual friend count descending.

/// <summary>
/// Get a list of players who may be your friends. Friends and blocklisted players will be filtered out.
/// And the result will be ordered by the mutual friend count descending.
/// </summary>
/// <param name="pgos_params">Request struct for get potential friends</param>
public void GetPotentialFriends(GetPotentialFriendsParams pgos_params, FriendDelegate6 callback);

Parameters:

ParamTypeDescription
pgos_paramsGetPotentialFriendsParamsRequest struct for get potential friends
callbackFriendDelegate6

Return: void

SetFriendRemark

Set remark to your friend, for example, "Tommy, a humorous man, met in the battle.", Max remark length: 32 characters.

/// <summary>Set remark to your friend, for example, "Tommy, a humorous man, met in the battle.",  Max remark length: 32 characters.</summary>
/// <param name="pgos_params">Request struct for set friend remark</param>
public void SetFriendRemark(SetFriendRemarkParams pgos_params, FriendDelegate1 callback);

Parameters:

ParamTypeDescription
pgos_paramsSetFriendRemarkParamsRequest struct for set friend remark
callbackFriendDelegate1

Return: void

SubscribeFriendPresence

Subscribe to the presence of all friends. You will be notified of presence changes from your friends.

/// <summary>Subscribe to the presence of all friends. You will be notified of presence changes from your friends.</summary>
public void SubscribeFriendPresence(FriendDelegate1 callback);

Parameters:

ParamTypeDescription
callbackFriendDelegate1

Return: void

UnsubscribeFriendPresence

Unsubscribe friend presence.

/// <summary>Unsubscribe friend presence.</summary>
public void UnsubscribeFriendPresence(FriendDelegate1 callback);

Parameters:

ParamTypeDescription
callbackFriendDelegate1

Return: void

GetMyFriendsLimit

Query the maximum limit of friends you can have.

/// <summary>Query the maximum limit of friends you can have.</summary>
public void GetMyFriendsLimit(FriendDelegate7 callback);

Parameters:

ParamTypeDescription
callbackFriendDelegate7

Return: void

GetMutualFriendsCount

Get mutual friends count between this player and target players.

/// <summary>Get mutual friends count between this player and target players.</summary>
/// <param name="pgos_params">Request struct for get mutual friends</param>
public void GetMutualFriendsCount(GetMutualFriendsCountParams pgos_params, FriendDelegate8 callback);

Parameters:

ParamTypeDescription
pgos_paramsGetMutualFriendsCountParamsRequest struct for get mutual friends
callbackFriendDelegate8

Return: void

Event Details

OnAddFriendRequest

The event will be triggered when receive a request to add friend.

/// <summary>The event will be triggered when receive a request to add friend.</summary>
public event FriendDelegate9 OnAddFriendRequest;

Type Reference:

OnAddFriendResponse

The event will be triggered when your add-friend request was accepted by player.

/// <summary>The event will be triggered when your add-friend request was accepted by player.</summary>
public event FriendDelegate10 OnAddFriendResponse;

Type Reference:

OnFriendRemoved

The event will be triggered when someone has remove you from his/her friend list.

/// <summary>The event will be triggered when someone has remove you from his/her friend list.</summary>
public event FriendDelegate11 OnFriendRemoved;

Type Reference:

OnBadgeNumOfFriendReq

The event will be triggered when the player login PGOS or the list of friend requests received changes.

/// <summary>The event will be triggered when the player login PGOS or the list of friend requests received changes.</summary>
public event FriendDelegate12 OnBadgeNumOfFriendReq;

Type Reference:

OnFriendPresenceChanged

The event will be triggered when the presence of a friend changed. The premise is that you must first subscribe to the friend presence.

/// <summary>The event will be triggered when the presence of a friend changed. The premise is that you must first subscribe to the friend presence.</summary>
public event FriendDelegate13 OnFriendPresenceChanged;

Type Reference:

All Delegates

public delegate void FriendDelegate0(PgosResult a0, FriendListInfo a1);
public delegate void FriendDelegate1(PgosResult a0);
public delegate void FriendDelegate2(PgosResult a0, FriendReqListInfo a1);
public delegate void FriendDelegate3(PgosResult a0, AcceptFriendRequestResult a1);
public delegate void FriendDelegate4(PgosResult a0, BatchAddFriendRsp a1);
public delegate void FriendDelegate5(PgosResult a0, PlayerSearchInfoList a1);
public delegate void FriendDelegate6(PgosResult a0, GetPotentialFriendsResult a1);
public delegate void FriendDelegate7(PgosResult a0, GetMyFriendsLimitResult a1);
public delegate void FriendDelegate8(PgosResult a0, GetMutualFriendsCountResult a1);
public delegate void FriendDelegate9(AddFriendRequestEvt a0);
public delegate void FriendDelegate10(AddFriendResponseEvt a0);
public delegate void FriendDelegate11(FriendRemovedEvt a0);
public delegate void FriendDelegate12(BadgeNumOfFriendReqEvt a0);
public delegate void FriendDelegate13(FriendPresenceChangedEvt a0);

Type Reference: