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.
Method | Description |
---|---|
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 Name | Description | Accessing Method |
---|---|---|
presence | The player's online state or the custom status-text. | GetOnlineState() GetCustomStatus() |
display_name | Refer to friend_remark if it isn't empty, or be simply equalent to player_name . | GetDisplayName() |
player_name | The player's user name on PGOS service. | GetPlayerName() |
friend_remark | A remark-name for your friend. | GetFriendRemark() |
avatar_uri | The avatar image and the avatar frame. | GetAvatarPackInfo() |
relationship | The relationship between you and a player. | GetRelationship() |
account_channel | The account channel this player being from. | GetAccountChannel() |
5. Player Relationship
UPgosPlayerInfoBase::GetRelationship()
returns the relationship:
Relationship (Enum Value) | Description |
---|---|
Friend | The player is in the friend list |
Blocked | The player is in the block list |
Stranger | The player is a stranger |
SelfPlayer | The player self |
SentFriendRequest | Sent a request to add |
ReceivedFriendRequest | Received Friend Requests |
Unknown | Can't get player relationship |