Skip to main content

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
SetOnLatencyTestRoundCompletedThe 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 player_id 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 result_callback The result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.
*/
void GetBattleRecordList(
const pgos::pstring& player_id,
const pgos::pvector<pgos::pstring>& tags,
const pgos::pvector<pgos::pstring>& keys,
int32_t offset,
int32_t count,
PgosDataCallback<BattleListInfo> result_callback);

Parameters:

ParamTypeDescription
player_idconst std::string&The player id to query
tagsconst std::vector<std::string>&Get the list for specific tags, if the tags is empty, the tag will not be filtered
keysconst std::vector<std::string>&Get the list for specific keys, if the keys is empty, the key will not be filtered
offsetint32_tThe starting position of the list
countint32_tThe count of the list
result_callbackPgosDataCallback<BattleListInfo>The result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.

Return: void

GetBattleBriefList

Get a list of battle brief

/**
* Get a list of battle brief
*
* @param player_id 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 result_callback The result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.
*/
void GetBattleBriefList(
const pgos::pstring& player_id,
const pgos::pvector<pgos::pstring>& tags,
int32_t offset,
int32_t count,
PgosDataCallback<BattleBriefListInfo> result_callback);

Parameters:

ParamTypeDescription
player_idconst std::string&The player id to query
tagsconst std::vector<std::string>&Get the list for specific tags, if the tags is empty, the tag will not be filtered
offsetint32_tThe starting position of the list
countint32_tThe count of the list
result_callbackPgosDataCallback<BattleBriefListInfo>The result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.

Return: void

GetBattleData

Get all battle data

/**
* Get all battle data
*
* @param battle_session_id 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 result_callback The result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.
*/
void GetBattleData(
const pgos::pstring& battle_session_id,
const pgos::pvector<pgos::pstring>& keys,
PgosDataCallback<BattleDataInfo> result_callback);

Parameters:

ParamTypeDescription
battle_session_idconst std::string&The battle session id to query
keysconst std::vector<std::string>&Get the list for specific keys, if the keys is empty, the key will not be filtered
result_callbackPgosDataCallback<BattleDataInfo>The result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.

Return: void

GetBattleDetail

Get the detail of the battle

/**
* Get the detail of the battle
*
* @param battle_session_id The battle session id to query
* @param result_callback The result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.
*/
void GetBattleDetail(
const pgos::pstring& battle_session_id,
PgosDataCallback<BattleDetailInfo> result_callback);

Parameters:

ParamTypeDescription
battle_session_idconst std::string&The battle session id to query
result_callbackPgosDataCallback<BattleDetailInfo>The result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.

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 result_callback The result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.
*/
void DescribePlayerBattleSession(
PgosDataCallback<PlayerBattleSessionInfo> result_callback);

Parameters:

ParamTypeDescription
result_callbackPgosDataCallback<PlayerBattleSessionInfo>The result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.

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 result_callback The result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.
*/
void DescribeBattleSessions(
PgosDataCallback<DescribeBattleSessionsResult> result_callback);

Parameters:

ParamTypeDescription
result_callbackPgosDataCallback<DescribeBattleSessionsResult>The result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.

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 battle_session_id The battle session id
* @param player_battle_session_id The player battle session id, !!! NOT BATTLE SESSION ID !!!
* @param result_callback The result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.
*/
void TerminatePlayerBattleSession(
const pgos::pstring& battle_session_id,
const pgos::pstring& player_battle_session_id,
PgosCallback result_callback);

Parameters:

ParamTypeDescription
battle_session_idconst std::string&The battle session id
player_battle_session_idconst std::string&The player battle session id, !!! NOT BATTLE SESSION ID !!!
result_callbackPgosCallbackThe result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.

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.
*/
DSHostingLatencies GetDSHostingLatencies();

Parameters:

(No parameters)

Return: DSHostingLatencies

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 result_callback The result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.
*/
void SetCustomDSHostingLatencies(
const DSHostingLatencies& latencies,
PgosCallback result_callback);

Parameters:

ParamTypeDescription
latenciesconst DSHostingLatencies&The custom latencies to set for DS hosting data centers.
result_callbackPgosCallbackThe result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.

Return: void

Event Details

SetOnLatencyTestRoundCompleted

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

/**
* OnSetOnLatencyTestRoundCompleted:
* The event will be triggered when a round of latency testing is completed.
*
* @param event Event details when a latency test round is completed.
*/
void SetOnLatencyTestRoundCompleted(
const LatencyTestRoundCompletedEvt& event);

Parameters:

ParamTypeDescription
eventconst LatencyTestRoundCompletedEvt&Event details when a latency test round is completed.