Skip to main content

Player Settings

1. Overview

The Setttings module provides the game with the ability to manage player-related settings. It usually corresponds to the settings interface of the game client. Currently, it consists of two sections: Privacy Settings and Local Cache Management.

After completing this tutorial, you will learn the following content:

  • How to get and set player privacy settings.
  • How to get local cache status and clear local cache.

2. Privacy Settings

Privacy Settings is a collection of settings that allows you to control who can socialize with you, currently it includes the following fields:

struct FClientPrivacySettingInfo 
{
/** Whether allow being searched by other players, true: allowed, false: not allowed. */
bool allow_searched_by_others;
/** Whether allow receiving other players' add-friend requests, true: allow, false: not allow. */
bool allow_friend_request;
/** Whether allow non-friend players to have a personal chat with you, true: allow, false: not allow. */
bool allow_nonfriend_perschat;
/** Whether allow other players to invite you to join a group, true: allow, false: not allow. */
bool allow_group_invitation;
/** Text and voice chat privacy settings. */
EClientPrivacyChatStrategy chat_strategy;
};

2.1 API Details

Operations supported:

APIDescription
GetPrivacySettingsQuery privacy settings of the currently logged in player.
SetPrivacySettingsSet privacy settings of the currently logged in player (all fields must be set together).
SetPrivacyItemSet privacy settings of the currently logged in player (Set one of the privacy options).

2.1.1 GetPrivacySettings Client API

Interface prototype:

/**
* Query privacy settings of the currently logged in player.
*/
void GetPrivacySettings(TFunction<void(const FPgosResult& Ret, const FClientPrivacySettingInfo* Data)> Callback) const;

Example Code:

#include "PgosSDKCpp.h"

void SomeUObjectClass::SomeFunction()
{
auto Settings = IPgosSDKCpp::Get().GetClientSettingsAPI();
if (Settings)
{
Settings->GetPrivacySettings([](const FPgosResult& Ret, const FClientPrivacySettingInfo* Data) {
if (Ret.err_code == (int32)Pgos::PgosErrCode::kSuccess)
{
UE_LOG(LogTemp, Log, TEXT("GetPrivacySettings Success"));
}
else
{
UE_LOG(LogTemp, Log, TEXT("GetPrivacySettings Failed: err_code=%d, err_msg=%s"), Ret.err_code, *Ret.msg);
}
});
}
}

2.1.2 SetPrivacySettings Client API

Interface prototype:

/**
* Set privacy settings of the currently logged in player (all fields must be set together).
*
* @param Settings New settings to be set.
*/
void SetPrivacySettings(
const FClientPrivacySettingInfo& Settings,
TFunction<void(const FPgosResult& Ret)> Callback) const;

Example Code:

#include "PgosSDKCpp.h"

void SomeUObjectClass::SomeFunction()
{
auto Settings = IPgosSDKCpp::Get().GetClientSettingsAPI();
if (Settings)
{
FClientPrivacySettingInfo Settings;
Settings.allow_searched_by_others = false;
Settings.allow_friend_request = false;
Settings.allow_nonfriend_perschat = false;
Settings.allow_group_invitation = false;
Settings->SetPrivacySettings(Settings, [](const FPgosResult& Ret) {
if (Ret.err_code == (int32)Pgos::PgosErrCode::kSuccess)
{
UE_LOG(LogTemp, Log, TEXT("SetPrivacySettings Success"));
}
else
{
UE_LOG(LogTemp, Log, TEXT("SetPrivacySettings Failed: err_code=%d, err_msg=%s"), Ret.err_code, *Ret.msg);
}
});
}
}

2.1.3 SetPrivacyItem Client API

Interface prototype:

/**
* Set privacy settings of the currently logged in player (Set one of the privacy options).
*
* @param Settings New settings to be set. Only the item corresponding to 'valid_item_type' will be modified.
* @param ValidItemType Specify a privacy item for modification.
*/
void SetPrivacyItem(
const FClientPrivacySettingInfo& Settings,
EClientPrivacyItemType ValidItemType,
TFunction<void(const FPgosResult& Ret)> Callback) const;

Example Code:

#include "PgosSDKCpp.h"

void SomeUObjectClass::SomeFunction()
{
auto Settings = IPgosSDKCpp::Get().GetClientSettingsAPI();
if (Settings)
{

FClientPrivacySettingInfo Settings;
Settings.chat_strategy = EClientPrivacyChatStrategy::Blocked;
EClientPrivacyItemType ValidItemType = EClientPrivacyItemType::ChatStrategy;
Settings->SetPrivacyItem(Settings, ValidItemType, [](const FPgosResult& Ret) {
if (Ret.err_code == (int32)Pgos::PgosErrCode::kSuccess)
{
UE_LOG(LogTemp, Log, TEXT("SetPrivacyItem Success"));
}
else
{
UE_LOG(LogTemp, Log, TEXT("SetPrivacyItem Failed: err_code=%d, err_msg=%s"), Ret.err_code, *Ret.msg);
}
});
}
}

2.2 Console Platform Compliance Instructions

Console compliance requires privacy settings(chat_strategy) in the console to take effect in the game. In order for PGOS to respond to this privacy setting, game developers need to sync this option from the console platform to PGOS.

The correspondence of privacy settings options between the console platform and PGOS: | Console Platform | Console Settings | PGOS Settings | | ---------------- | ---------------- | ------------- | | XBOX | Everyone | Allow | | XBOX | Friends | OnlyFriends | | XBOX | Blocked | Blocked | | PS5 | Everyone | Allow | | PS5 | Friends | OnlyFriends | | PS5 | Friend of Friend | OnlyFriends | | PS5 | Blocked | Blocked |

3. Local Cache

In order to improve performance efficiency, PgosSDK will store some reusable data locally in the form of files. The following are modules that may generate local cache:

  • Personal Chat: local cache for storing chat lists and message content.
  • Title Region Config Data: local cache for storing key-value pairs obtained from recent requests, with version control to ensure that the values are up-to-date.

The game can set the chat_msg_cache_max_bytes and title_data_cache_max_bytes configuration items to control the maximum size of the local cache. If the size is exceeded, PgosSDK will automatically clean up the older cache. Click here to see how to set the configuration items.

Players may be interested in the size of the current local cache on their machine, the game can show it to the player, and it is up to the player to decide if it needs to be cleaned up. Clearing the local cache will not affect the correctness of the PGOS service, so do so with confidence if necessary.

3.1 API Details

Operations supported:

APIDescription
GetLocalCacheSizeGet total bytes of local cache files
ClearLocalCacheClear local cache files.

3.1.1 GetLocalCacheSize Client API

Interface prototype:

/**
* Get total bytes of local cache files
*
* @return Bytes of local cache file
*/
int64 GetLocalCacheSize() const;

Example Code:

#include "PgosSDKCpp.h"

void SomeUObjectClass::SomeFunction()
{
auto Settings = IPgosSDKCpp::Get().GetClientSettingsAPI();
if (Settings)
{
auto PgosLocalCacheSize = Settings->GetLocalCacheSize();
// TODO: display it on the UI.
}
}

3.1.2 ClearLocalCache Client API

Interface prototype:

/**
* Clear local cache files
*/
void ClearLocalCache(TFunction<void(const FPgosResult& Ret)> Callback) const;

Example Code:

#include "PgosSDKCpp.h"

void SomeUObjectClass::SomeFunction()
{
auto Settings = IPgosSDKCpp::Get().GetClientSettingsAPI();
if (Settings)
{
Settings->ClearLocalCache([](const FPgosResult& Ret) {
if (Ret.err_code == (int32)Pgos::PgosErrCode::kSuccess)
{
UE_LOG(LogTemp, Log, TEXT("ClearLocalCache Success"));
}
else
{
UE_LOG(LogTemp, Log, TEXT("ClearLocalCache Failed: err_code=%d, err_msg=%s"), Ret.err_code, *Ret.msg);
}
});
}
}