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
| API | Description |
|---|---|
| GetBattleRecordList | Get a list of battle records |
| GetBattleBriefList | Get a list of battle brief |
| GetBattleData | Get all battle data |
| GetBattleDetail | Get the detail of the battle |
| DescribePlayerBattleSession | Get the player's battle session info. |
| DescribeBattleSessions | Get a list of the battle sesions that the player is participating in. |
| TerminatePlayerBattleSession | Try to terminate the player session in a P2P battle. The player session status will turn to Completed after interface is called. |
| 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. |
| 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. |
Event List
| Event | Description |
|---|---|
| OnLatencyTestRoundCompleted | The 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:
| Param | Type | Description |
|---|---|---|
| PlayerId | const FString& | The player id to query |
| Tags | const TArray<FString>& | Get the list for specific tags, if the tags is empty, the tag will not be filtered |
| Keys | const TArray<FString>& | Get the list for specific keys, if the keys is empty, the key will not be filtered |
| Offset | int32 | The starting position of the list |
| Count | int32 | The count of the list |
| ResultCallback | TFunction<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:
| Param | Type | Description |
|---|---|---|
| PlayerId | const FString& | The player id to query |
| Tags | const TArray<FString>& | Get the list for specific tags, if the tags is empty, the tag will not be filtered |
| Offset | int32 | The starting position of the list |
| Count | int32 | The count of the list |
| ResultCallback | TFunction<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:
| Param | Type | Description |
|---|---|---|
| BattleSessionId | const FString& | The battle session id to query |
| Keys | const TArray<FString>& | Get the list for specific keys, if the keys is empty, the key will not be filtered |
| ResultCallback | TFunction<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:
| Param | Type | Description |
|---|---|---|
| BattleSessionId | const FString& | The battle session id to query |
| ResultCallback | TFunction<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:
| Param | Type | Description |
|---|---|---|
| ResultCallback | TFunction<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:
| Param | Type | Description |
|---|---|---|
| ResultCallback | TFunction<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:
| Param | Type | Description |
|---|---|---|
| BattleSessionId | const FString& | The battle session id |
| PlayerBattleSessionId | const FString& | The player battle session id, !!! NOT BATTLE SESSION ID !!! |
| ResultCallback | TFunction<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:
| Param | Type | Description |
|---|---|---|
| Latencies | const FPgosClientDSHostingLatencies& | The custom latencies to set for DS hosting data centers. |
| ResultCallback | TFunction<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: