跳到主要内容

Server 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
UpdateBattleRecordNow, there is no need to manually establish the association between battle session id and player ids, as PGOS will automatically complete this task.
SetBattleTagsSet tags for a battle session record.
UpdateBattleDataUpdate the data of battle
UpdateBattleBriefUpdate the brief of battle
UpdateBattleDetailUpdate the detail of battle.
DeleteBattleDataDelete the data of the specified key of battle

API Details

UpdateBattleRecord

Now, there is no need to manually establish the association between battle session id and player ids, as PGOS will automatically complete this task.

Deprecated, use SetBattleTags instead.

/**
* Now, there is no need to manually establish the association between battle session id and player ids, as PGOS will automatically complete this task.
* [DEPRECATED!!!] UpdateBattleRecord was declared deprecated, consider using SetBattleTags instead.
*
* @param battle_session_id The id of battle session.
* @param player_ids IDs of all players in the battle, array cannot be empty.
* @param tags The tags of battle.
* @param result_callback The result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.
*/
void UpdateBattleRecord(
const pgos::pstring& battle_session_id,
const pgos::pvector<pgos::pstring>& player_ids,
const pgos::pvector<pgos::pstring>& tags,
PgosCallback result_callback);

Parameters:

ParamTypeDescription
battle_session_idconst std::string&The id of battle session.
player_idsconst std::vector<std::string>&IDs of all players in the battle, array cannot be empty.
tagsconst std::vector<std::string>&The tags of battle.
result_callbackPgosCallbackThe result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.

Return: void

SetBattleTags

Set tags for a battle session record.

/**
* Set tags for a battle session record.
*
* @param result_callback The result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.
*/
void SetBattleTags(
const SetBattleTagsParams& params,
PgosCallback result_callback);

Parameters:

ParamTypeDescription
paramsconst SetBattleTagsParams&
result_callbackPgosCallbackThe result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.

Return: void

UpdateBattleData

Update the data of battle

/**
* Update the data of battle
*
* @param battle_session_id The id of battle session.
* @param record_data The data of battle.
* @param result_callback The result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.
*/
void UpdateBattleData(
const pgos::pstring& battle_session_id,
const pgos::pmap<pgos::pstring, pgos::pstring>& record_data,
PgosCallback result_callback);

Parameters:

ParamTypeDescription
battle_session_idconst std::string&The id of battle session.
record_dataconst std::map<std::string, std::string>&The data of battle.
result_callbackPgosCallbackThe result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.

Return: void

UpdateBattleBrief

Update the brief of battle

/**
* Update the brief of battle
*
* @param battle_session_id The id of battle session.
* @param brief The data of battle.
* @param result_callback The result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.
*/
void UpdateBattleBrief(
const pgos::pstring& battle_session_id,
const pgos::pstring& brief,
PgosCallback result_callback);

Parameters:

ParamTypeDescription
battle_session_idconst std::string&The id of battle session.
briefconst std::string&The data of battle.
result_callbackPgosCallbackThe result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.

Return: void

UpdateBattleDetail

Update the detail of battle.

/**
* Update the detail of battle.
*
* @param battle_session_id The id of battle session.
* @param detail The data of battle.
* @param result_callback The result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.
*/
void UpdateBattleDetail(
const pgos::pstring& battle_session_id,
const pgos::pstring& detail,
PgosCallback result_callback);

Parameters:

ParamTypeDescription
battle_session_idconst std::string&The id of battle session.
detailconst std::string&The data of battle.
result_callbackPgosCallbackThe result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.

Return: void

DeleteBattleData

Delete the data of the specified key of battle

/**
* Delete the data of the specified key of battle
*
* @param battle_session_id The id of battle session.
* @param keys The specified keys to be deleted, if the keys is empty, nothing will happen.
* @param result_callback The result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.
*/
void DeleteBattleData(
const pgos::pstring& battle_session_id,
const pgos::pvector<pgos::pstring>& keys,
PgosDataCallback<DelBattleDataRsp> result_callback);

Parameters:

ParamTypeDescription
battle_session_idconst std::string&The id of battle session.
keysconst std::vector<std::string>&The specified keys to be deleted, if the keys is empty, nothing will happen.
result_callbackPgosDataCallback<DelBattleDataRsp>The result callback after the API execution ends, and it will be called in an ASYNCHRONOUS CHILD THREAD.

Return: void