Skip to main content

Contacts

1. Get Contacts Manager

UPgosContactsManager provides the ability to access the player info, query players and manage the player objects.

UPgosContactsManager* ContactsManager = UPgosBlueprintFunctionLibrary::GetOverlayContactsManager();

2. Player Management API

All player management API are asynchronous, listen to URequestProc::Finished if you want to get noticed after the request finished.

MethodDescription
SetName(const FString& InDisplayName, bool bSetForEmptyOnly = true)Change your player name.
SetCustomStatus(const FString& InStatusName)Change the custom status-text of yourself. It's only valid for the current session, and will be automatically reset after logout.
SetAvatarImage(const FString& InAvatarImage)Change the avatar image of yourself.
SetAvatarFrame(const FString& InAvatarImage)Change the avatar frame of yourself.
SetAvatarPack(const FPgosAvatarPackInfo& InAvatarPackInfo)Change the avatar image and avatar frame at the same time.
BlockPlayer(const FString& InPlayerId)Add a player with the InPlayerId into your player blocklist.
UnblockPlayer(const FString& InPlayerId)Remove a player with the InPlayerId from your player blocklist.
AddFriend(const FString& InPlayerId)Send a friend request to a player with the InPlayerId.
RemoveFriend(const FString& InPlayerId)Remove a player with the InPlayerId from your friend list.
SetFriendRemark(const FClientSetFriendRemarkParams& Params)Change the remark of your friend.
NOTE: The player name will be displayed if the remark you given is empty.
AcceptRequest(const FString& InPlayerId)Accept a friend request you received.
RejectRequest(const FString& InPlayerId)Reject a friend request you received.

3. Query Player Objects

Get Player Object

// get a player object with PlayerId, if the player is not available in local cache, it'll return a placeholder player object
// the detail information of this player may be updated later asynchronously and automatically.
UPgosPlayerInfoBase* PlayerInfo = ContactsManager->GetPlayerObject(PlayerId);

Find Player Object

// find a player object with PlayerId, if the player is not available in local cache, it'll simply return nullptr.
UPgosPlayerInfoBase* PlayerInfo = ContactsManager->FindPlayerObject(PlayerId);

Get All Friends

TArray<UPgosPlayerInfoBase*> Results;
ContactsManager->SearchAllFriends(TEXT(""), Results);

4. Player Object Methods

UPgosPlayerInfoBase provides several methods to access the detail information of a player. All properties of UPgosPlayerInfoBase object are updated asynchronously, you need to register a callback on UPgosPlayerInfoBase::InfoUpdated, it'll invoked with the name of the property once it's value has been changed.

Property NameDescriptionAccessing Method
presenceThe player's online state or the custom status-text.GetOnlineState()
GetCustomStatus()
display_nameRefer to friend_remark if it isn't empty, or be simply equalent to player_name.GetDisplayName()
player_nameThe player's user name on PGOS service.GetPlayerName()
friend_remarkA remark-name for your friend.GetFriendRemark()
avatar_uriThe avatar image and the avatar frame.GetAvatarPackInfo()
relationshipThe relationship between you and a player.GetRelationship()
account_channelThe account channel this player being from.GetAccountChannel()

5. Player Relationship

UPgosPlayerInfoBase::GetRelationship() returns the relationship:

Relationship (Enum Value)Description
FriendThe player is in the friend list
BlockedThe player is in the block list
StrangerThe player is a stranger
SelfPlayerThe player self
SentFriendRequestSent a request to add
ReceivedFriendRequestReceived Friend Requests
UnknownCan't get player relationship