Skip to main content

Title Config Data

1. Overview

Title Config Data is a set of key-value pairs for the whole title. It is commonly used to store configuration data that is applicable across the title-wide, such as title region info list, game client version control data, and so on. It is readable by both the game client and game server, but can only be updated via the portal console or CLI.

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

  • How to customize title config data on the portal console.
  • How to query title config data in code.

2. Customize Title Config Data

Log in to the web portal, enter the console:

image-20240628193530646

Click the Global Data link on the top, active the Config Data tab:

image-20240628193135475

2.1 Add New Item

Click the Add button to add a new item:

image-20240628194149432

Field description:

  • Key: Name of the item, composed of letters, numbers, underscores, and spaces, it must start with a letter and cannot exceed 128 characters.

  • Is Json: Whether the Item value is required to comply with JSON constraints. If the developer wants to access this item value as a JsonValue in the code, it is recommended to set it to true and this will make a JSON constraint checking when editing the value.

  • Server Only: Whether the item can only be accessed by the server.

    • True: readable to the game sever and invisible to the game client.
    • False: readable to the game sever and the game client.
  • Description: Item description information, only used for item management, invisible to PgosSDK.

  • Value: Value of the item, the maximum character length is 1048576 (1*1024*1024).

    • The string value obtained through PgosSDK query will be:

      • If Is Json is false: the same string as in the edit box.
      • If Is Json is true: the string after removing blank characters in the edit box (to save transmission bandwidth).

      Item value will be presented in the form of FKVDataValue structure, the developer can use the functions: AsStr, AsInt32, AsInt64, AsFloat, AsDouble, AsJson to get the data format he/she wants.

Click the OK button to submit the creation. The game can have a maximum of 1000 Title Config Data items.

2.2 Edit Item Fields

If the developer wants to modify the item field, click the Edit link in the Operation column:

image-20240628194946397

Pop-up editing panel:

image-20240628195030643

When Is Json is set to true, the Value edit box will check JSON constraints.

2.3 Remove Existing Item

If you no longer need some items, you can select them and click the Remove button to remove them.

image-20240628195318051

3. Query Title Config Data

You can query the specified Title Config Data items in the game through PgosSDK.

3.1 For Game Client

APIDescription
GetTitleConfigKVDataQuery the specified key-value data of the title config data.
GetAllTitleConfigKVDataQuery all key-value data of the title config data.

GetTitleConfigKVData Client API

API prototype:

/**
* Query the specified key-value data of the title config data.
*
* @param QueryKeys Keys to query
*/
void GetTitleConfigKVData(
const TArray<FString>& QueryKeys,
TFunction<void(const FPgosResult& Ret, const FTitleConfigKVDataQueryResult* Data)> Callback) const;

Example Code:

#include "PgosSDKCpp.h"

void SomeUObjectClass::SomeFunction()
{
auto TitleConfigData = IPgosSDKCpp::Get().GetClientTitleConfigDataAPI();
if (TitleConfigData)
{
TArray<FString> QueryKeys;
QueryKeys.Add(TEXT("ClientMinimumSupportedVersionInfo"));
TitleConfigData->GetTitleConfigKVData(QueryKeys, [](const FPgosResult& Ret, const FTitleConfigKVDataQueryResult* Data) {
if (Ret.err_code == (int32)Pgos::PgosErrCode::kSuccess)
{
UE_LOG(LogTemp, Log, TEXT("GetTitleConfigKVData Success"));
}
else
{
UE_LOG(LogTemp, Log, TEXT("GetTitleConfigKVData Failed: err_code=%d, err_msg=%s"), Ret.err_code, *Ret.msg);
}
});
}
}

GetAllTitleConfigKVData Client API

API prototype:

/**
* Query all key-value data of the title config data.
*/
void GetAllTitleConfigKVData(TFunction<void(const FPgosResult& Ret, const FTitleConfigKVDataQueryResult* Data)> Callback) const;

Example Code:

#include "PgosSDKCpp.h"

void SomeUObjectClass::SomeFunction()
{
auto TitleConfigData = IPgosSDKCpp::Get().GetClientTitleConfigDataAPI();
if (TitleConfigData)
{

TitleConfigData->GetAllTitleConfigKVData([](const FPgosResult& Ret, const FTitleConfigKVDataQueryResult* Data) {
if (Ret.err_code == (int32)Pgos::PgosErrCode::kSuccess)
{
UE_LOG(LogTemp, Log, TEXT("GetAllTitleConfigKVData Success"));
}
else
{
UE_LOG(LogTemp, Log, TEXT("GetAllTitleConfigKVData Failed: err_code=%d, err_msg=%s"), Ret.err_code, *Ret.msg);
}
});
}
}

3.2 For Game Server

APIDescription
GetTitleConfigKVDataQuery the specified key-value data of the title config data.
GetAllTitleConfigKVDataQuery all key-value data of the title config data.

GetTitleConfigKVData Server API

API prototype:

/**
* Query the specified key-value data of the title config data.
*
* @param QueryKeys Keys to query
*/
void GetTitleConfigKVData(
const TArray<FString>& QueryKeys,
TFunction<void(const FPgosResult& Ret, const FTitleConfigKVDataQueryResult* Data)> Callback) const;

Example Code:

#include "PgosSDKCpp.h"

void SomeUObjectClass::SomeFunction()
{
auto TitleConfigData = IPgosSDKCpp::Get().GetServerTitleConfigDataAPI();
if (TitleConfigData)
{
TArray<FString> QueryKeys;
QueryKeys.Add(TEXT("Key_ServerOnly_1"));
TitleConfigData->GetTitleConfigKVData(QueryKeys, [](const FPgosResult& Ret, const FTitleConfigKVDataQueryResult* Data) {
if (Ret.err_code == (int32)Pgos::PgosErrCode::kSuccess)
{
UE_LOG(LogTemp, Log, TEXT("GetTitleConfigKVData Success"));
}
else
{
UE_LOG(LogTemp, Log, TEXT("GetTitleConfigKVData Failed: err_code=%d, err_msg=%s"), Ret.err_code, *Ret.msg);
}
});
}
}

GetAllTitleConfigKVData Server API

API prototype:

/**
* Query all key-value data of the title config data.
*/
void GetAllTitleConfigKVData(TFunction<void(const FPgosResult& Ret, const FTitleConfigKVDataQueryResult* Data)> Callback) const;

Example Code:

#include "PgosSDKCpp.h"

void SomeUObjectClass::SomeFunction()
{
auto TitleConfigData = IPgosSDKCpp::Get().GetServerTitleConfigDataAPI();
if (TitleConfigData)
{

TitleConfigData->GetAllTitleConfigKVData([](const FPgosResult& Ret, const FTitleConfigKVDataQueryResult* Data) {
if (Ret.err_code == (int32)Pgos::PgosErrCode::kSuccess)
{
UE_LOG(LogTemp, Log, TEXT("GetAllTitleConfigKVData Success"));
}
else
{
UE_LOG(LogTemp, Log, TEXT("GetAllTitleConfigKVData Failed: err_code=%d, err_msg=%s"), Ret.err_code, *Ret.msg);
}
});
}
}

3.3 Key Errors Handling

Error CodeRelevant APIHandling Suggestion
kBackendServerValidateFailGetTitleConfigKVData Client API
GetAllTitleConfigKVData Client API
GetTitleConfigKVData Server API
GetAllTitleConfigKVData Server API
the input parameter is invalid, check error msg for detail.
kBackendAllFailedGetTitleConfigKVData Client API
GetAllTitleConfigKVData Client API
GetTitleConfigKVData Server API
GetAllTitleConfigKVData Server API
all the data to be queried failed, please check the 'fails' field to get the failure reason.
kSdkNetworkErrorAll Network APInetwork error, check error msg for detail.