跳到主要内容

Client Battle API Reference

Battle session is the foundation of battle service. Battle session instances can be created through services such as Lobby / Matchmaking / World or via the PGOS HTTP API, and placed in online or local DS via the DS Hosting service. The battle session also manages data such as the players in the game and the DS access information.

API List

APIDescription
GetBattleRecordListGet a list of battle records
GetBattleBriefListGet a list of battle brief
GetBattleDataGet all battle data
GetBattleDetailGet the detail of the battle
DescribePlayerBattleSessionGet the player's battle session info.
DescribeBattleSessionsGet a list of the battle sesions that the player is participating in.
TerminatePlayerBattleSessionTry to terminate the player session in a P2P battle. The player session status will turn to Completed after interface is called.
GetDSHostingLatenciesObtain the latencies from the client to the DS hosting data centers. In general, the first round of latency testing will be completed in approximately 2~3 seconds after logging into PGOS. If the API is called before the testing is completed, or an exception occurs, the latency data returned by the API will be empty.
SetCustomDSHostingLatenciesSet custom latencies for the DS hosting data centers. This API is used to set custom latency values for different DS hosting data centers, which can be useful for testing purposes. After setting custom latencies, the client will use these values instead of the actual measured latencies when selecting a DS hosting data center.

Event List

EventDescription
OnLatencyTestRoundCompletedThe event will be triggered when a round of latency testing is completed.

API Details

GetBattleRecordList

Get a list of battle records

/**
* Get a list of battle records
*
* @param PlayerId The player id to query
* @param Tags Get the list for specific tags, if the tags is empty, the tag will not be filtered
* @param Keys Get the list for specific keys, if the keys is empty, the key will not be filtered
* @param Offset The starting position of the list
* @param Count The count of the list
* @param ResultCallback The result callback after the API execution ends, and it will be called in the GAME THREAD. For lifetime safety, it is recommended to use the CreateWeakCallback provided in PgosSDKCpp.h to create a lambda bound to an UObject.
*/
void GetBattleRecordList(
const FString& PlayerId,
const TArray<FString>& Tags,
const TArray<FString>& Keys,
int32 Offset,
int32 Count,
TFunction<void(const FPgosResult& Ret, const FPgosClientBattleListInfo* Data)> ResultCallback) const;

Parameters:

ParamTypeDescription
PlayerIdconst FString&The player id to query
Tagsconst TArray<FString>&Get the list for specific tags, if the tags is empty, the tag will not be filtered
Keysconst TArray<FString>&Get the list for specific keys, if the keys is empty, the key will not be filtered
Offsetint32The starting position of the list
Countint32The count of the list
ResultCallbackTFunction<void(const FPgosResult& Ret, const FPgosClientBattleListInfo* Data)>The result callback after the API execution ends, and it will be called in the GAME THREAD. For lifetime safety, it is recommended to use the CreateWeakCallback provided in PgosSDKCpp.h to create a lambda bound to an UObject.

Return: void

GetBattleBriefList

Get a list of battle brief

/**
* Get a list of battle brief
*
* @param PlayerId The player id to query
* @param Tags Get the list for specific tags, if the tags is empty, the tag will not be filtered
* @param Offset The starting position of the list
* @param Count The count of the list
* @param ResultCallback The result callback after the API execution ends, and it will be called in the GAME THREAD. For lifetime safety, it is recommended to use the CreateWeakCallback provided in PgosSDKCpp.h to create a lambda bound to an UObject.
*/
void GetBattleBriefList(
const FString& PlayerId,
const TArray<FString>& Tags,
int32 Offset,
int32 Count,
TFunction<void(const FPgosResult& Ret, const FPgosClientBattleBriefListInfo* Data)> ResultCallback) const;

Parameters:

ParamTypeDescription
PlayerIdconst FString&The player id to query
Tagsconst TArray<FString>&Get the list for specific tags, if the tags is empty, the tag will not be filtered
Offsetint32The starting position of the list
Countint32The count of the list
ResultCallbackTFunction<void(const FPgosResult& Ret, const FPgosClientBattleBriefListInfo* Data)>The result callback after the API execution ends, and it will be called in the GAME THREAD. For lifetime safety, it is recommended to use the CreateWeakCallback provided in PgosSDKCpp.h to create a lambda bound to an UObject.

Return: void

GetBattleData

Get all battle data

/**
* Get all battle data
*
* @param BattleSessionId The battle session id to query
* @param Keys Get the list for specific keys, if the keys is empty, the key will not be filtered
* @param ResultCallback The result callback after the API execution ends, and it will be called in the GAME THREAD. For lifetime safety, it is recommended to use the CreateWeakCallback provided in PgosSDKCpp.h to create a lambda bound to an UObject.
*/
void GetBattleData(
const FString& BattleSessionId,
const TArray<FString>& Keys,
TFunction<void(const FPgosResult& Ret, const FPgosClientBattleDataInfo* Data)> ResultCallback) const;

Parameters:

ParamTypeDescription
BattleSessionIdconst FString&The battle session id to query
Keysconst TArray<FString>&Get the list for specific keys, if the keys is empty, the key will not be filtered
ResultCallbackTFunction<void(const FPgosResult& Ret, const FPgosClientBattleDataInfo* Data)>The result callback after the API execution ends, and it will be called in the GAME THREAD. For lifetime safety, it is recommended to use the CreateWeakCallback provided in PgosSDKCpp.h to create a lambda bound to an UObject.

Return: void

GetBattleDetail

Get the detail of the battle

/**
* Get the detail of the battle
*
* @param BattleSessionId The battle session id to query
* @param ResultCallback The result callback after the API execution ends, and it will be called in the GAME THREAD. For lifetime safety, it is recommended to use the CreateWeakCallback provided in PgosSDKCpp.h to create a lambda bound to an UObject.
*/
void GetBattleDetail(
const FString& BattleSessionId,
TFunction<void(const FPgosResult& Ret, const FPgosClientBattleDetailInfo* Data)> ResultCallback) const;

Parameters:

ParamTypeDescription
BattleSessionIdconst FString&The battle session id to query
ResultCallbackTFunction<void(const FPgosResult& Ret, const FPgosClientBattleDetailInfo* Data)>The result callback after the API execution ends, and it will be called in the GAME THREAD. For lifetime safety, it is recommended to use the CreateWeakCallback provided in PgosSDKCpp.h to create a lambda bound to an UObject.

Return: void

DescribePlayerBattleSession

Get the player's battle session info.

Deprecated, use DescribeBattleSessions instead.

/**
* Get the player's battle session info.
* [DEPRECATED!!!] DescribePlayerBattleSession was declared deprecated, consider using DescribeBattleSessions instead.
*
* @param ResultCallback The result callback after the API execution ends, and it will be called in the GAME THREAD. For lifetime safety, it is recommended to use the CreateWeakCallback provided in PgosSDKCpp.h to create a lambda bound to an UObject.
*/
void DescribePlayerBattleSession(
TFunction<void(const FPgosResult& Ret, const FPgosClientPlayerBattleSessionInfo* Data)> ResultCallback) const;

Parameters:

ParamTypeDescription
ResultCallbackTFunction<void(const FPgosResult& Ret, const FPgosClientPlayerBattleSessionInfo* Data)>The result callback after the API execution ends, and it will be called in the GAME THREAD. For lifetime safety, it is recommended to use the CreateWeakCallback provided in PgosSDKCpp.h to create a lambda bound to an UObject.

Return: void

DescribeBattleSessions

Get a list of the battle sesions that the player is participating in.

/**
* Get a list of the battle sesions that the player is participating in.
*
* @param ResultCallback The result callback after the API execution ends, and it will be called in the GAME THREAD. For lifetime safety, it is recommended to use the CreateWeakCallback provided in PgosSDKCpp.h to create a lambda bound to an UObject.
*/
void DescribeBattleSessions(
TFunction<void(const FPgosResult& Ret, const FPgosClientDescribeBattleSessionsResult* Data)> ResultCallback) const;

Parameters:

ParamTypeDescription
ResultCallbackTFunction<void(const FPgosResult& Ret, const FPgosClientDescribeBattleSessionsResult* Data)>The result callback after the API execution ends, and it will be called in the GAME THREAD. For lifetime safety, it is recommended to use the CreateWeakCallback provided in PgosSDKCpp.h to create a lambda bound to an UObject.

Return: void

TerminatePlayerBattleSession

Try to terminate the player session in a P2P battle. The player session status will turn to Completed after interface is called.

/**
* Try to terminate the player session in a P2P battle. The player session status will turn to Completed after interface is called.
*
* @param BattleSessionId The battle session id
* @param PlayerBattleSessionId The player battle session id, !!! NOT BATTLE SESSION ID !!!
* @param ResultCallback The result callback after the API execution ends, and it will be called in the GAME THREAD. For lifetime safety, it is recommended to use the CreateWeakCallback provided in PgosSDKCpp.h to create a lambda bound to an UObject.
*/
void TerminatePlayerBattleSession(
const FString& BattleSessionId,
const FString& PlayerBattleSessionId,
TFunction<void(const FPgosResult& Ret)> ResultCallback) const;

Parameters:

ParamTypeDescription
BattleSessionIdconst FString&The battle session id
PlayerBattleSessionIdconst FString&The player battle session id, !!! NOT BATTLE SESSION ID !!!
ResultCallbackTFunction<void(const FPgosResult& Ret)>The result callback after the API execution ends, and it will be called in the GAME THREAD. For lifetime safety, it is recommended to use the CreateWeakCallback provided in PgosSDKCpp.h to create a lambda bound to an UObject.

Return: void

GetDSHostingLatencies

Obtain the latencies from the client to the DS hosting data centers. In general, the first round of latency testing will be completed in approximately 2~3 seconds after logging into PGOS. If the API is called before the testing is completed, or an exception occurs, the latency data returned by the API will be empty.

/**
* Obtain the latencies from the client to the DS hosting data centers.
* In general, the first round of latency testing will be completed in approximately 2~3 seconds after logging into PGOS.
* If the API is called before the testing is completed, or an exception occurs, the latency data returned by the API will be empty.
*
* @return The latencies from the client to the DS hosting data centers.
*/
FPgosClientDSHostingLatencies GetDSHostingLatencies() const;

Parameters:

(No parameters)

Return: FPgosClientDSHostingLatencies

The latencies from the client to the DS hosting data centers.

SetCustomDSHostingLatencies

Set custom latencies for the DS hosting data centers. This API is used to set custom latency values for different DS hosting data centers, which can be useful for testing purposes. After setting custom latencies, the client will use these values instead of the actual measured latencies when selecting a DS hosting data center.

/**
* Set custom latencies for the DS hosting data centers.
* This API is used to set custom latency values for different DS hosting data centers, which can be useful for testing purposes.
* After setting custom latencies, the client will use these values instead of the actual measured latencies when selecting a DS hosting data center.
*
* @param Latencies The custom latencies to set for DS hosting data centers.
* @param ResultCallback The result callback after the API execution ends, and it will be called in the GAME THREAD. For lifetime safety, it is recommended to use the CreateWeakCallback provided in PgosSDKCpp.h to create a lambda bound to an UObject.
*/
void SetCustomDSHostingLatencies(
const FPgosClientDSHostingLatencies& Latencies,
TFunction<void(const FPgosResult& Ret)> ResultCallback) const;

Parameters:

ParamTypeDescription
Latenciesconst FPgosClientDSHostingLatencies&The custom latencies to set for DS hosting data centers.
ResultCallbackTFunction<void(const FPgosResult& Ret)>The result callback after the API execution ends, and it will be called in the GAME THREAD. For lifetime safety, it is recommended to use the CreateWeakCallback provided in PgosSDKCpp.h to create a lambda bound to an UObject.

Return: void

Event Details

OnLatencyTestRoundCompleted

The event will be triggered when a round of latency testing is completed.

/**
* OnLatencyTestRoundCompleted:
* The event will be triggered when a round of latency testing is completed.
*
* @param Event Event details when a latency test round is completed.
*/
DECLARE_MULTICAST_DELEGATE_OneParam(FOnLatencyTestRoundCompleted, const FPgosClientLatencyTestRoundCompletedEvt& /*Event*/);
FOnLatencyTestRoundCompleted& OnLatencyTestRoundCompleted() { return LatencyTestRoundCompletedDelegate; }

Type Reference: