跳到主要内容

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

/// <summary>Get a list of battle records</summary>
/// <param name="player_id">The player id to query</param>
/// <param name="tags">Get the list for specific tags, if the tags is empty, the tag will not be filtered</param>
/// <param name="keys">Get the list for specific keys, if the keys is empty, the key will not be filtered</param>
/// <param name="offset">The starting position of the list</param>
/// <param name="count">The count of the list</param>
public void GetBattleRecordList(string player_id, List<string> tags, List<string> keys, Int32 offset, Int32 count, BattleDelegate0 callback);

Parameters:

ParamTypeDescription
player_idstringThe player id to query
tagsList<string>Get the list for specific tags, if the tags is empty, the tag will not be filtered
keysList<string>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
callbackBattleDelegate0

Return: void

GetBattleBriefList

Get a list of battle brief

/// <summary>Get a list of battle brief</summary>
/// <param name="player_id">The player id to query</param>
/// <param name="tags">Get the list for specific tags, if the tags is empty, the tag will not be filtered</param>
/// <param name="offset">The starting position of the list</param>
/// <param name="count">The count of the list</param>
public void GetBattleBriefList(string player_id, List<string> tags, Int32 offset, Int32 count, BattleDelegate1 callback);

Parameters:

ParamTypeDescription
player_idstringThe player id to query
tagsList<string>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
callbackBattleDelegate1

Return: void

GetBattleData

Get all battle data

/// <summary>Get all battle data</summary>
/// <param name="battle_session_id">The battle session id to query</param>
/// <param name="keys">Get the list for specific keys, if the keys is empty, the key will not be filtered</param>
public void GetBattleData(string battle_session_id, List<string> keys, BattleDelegate2 callback);

Parameters:

ParamTypeDescription
battle_session_idstringThe battle session id to query
keysList<string>Get the list for specific keys, if the keys is empty, the key will not be filtered
callbackBattleDelegate2

Return: void

GetBattleDetail

Get the detail of the battle

/// <summary>Get the detail of the battle</summary>
/// <param name="battle_session_id">The battle session id to query</param>
public void GetBattleDetail(string battle_session_id, BattleDelegate3 callback);

Parameters:

ParamTypeDescription
battle_session_idstringThe battle session id to query
callbackBattleDelegate3

Return: void

DescribePlayerBattleSession

Get the player's battle session info.

Deprecated, use DescribeBattleSessions instead.

/// <summary>Get the player's battle session info.</summary>
public void DescribePlayerBattleSession(BattleDelegate4 callback);

Parameters:

ParamTypeDescription
callbackBattleDelegate4

Return: void

DescribeBattleSessions

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

/// <summary>Get a list of the battle sesions that the player is participating in.</summary>
public void DescribeBattleSessions(BattleDelegate5 callback);

Parameters:

ParamTypeDescription
callbackBattleDelegate5

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.

/// <summary>Try to terminate the player session in a P2P battle. The player session status will turn to Completed after interface is called.</summary>
/// <param name="battle_session_id">The battle session id</param>
/// <param name="player_battle_session_id">The player battle session id, !!! NOT BATTLE SESSION ID !!!</param>
public void TerminatePlayerBattleSession(string battle_session_id, string player_battle_session_id, BattleDelegate6 callback);

Parameters:

ParamTypeDescription
battle_session_idstringThe battle session id
player_battle_session_idstringThe player battle session id, !!! NOT BATTLE SESSION ID !!!
callbackBattleDelegate6

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.

/// <summary>
/// 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.
/// </summary>
public 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.

/// <summary>
/// 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.
/// </summary>
/// <param name="latencies">The custom latencies to set for DS hosting data centers.</param>
public void SetCustomDSHostingLatencies(DSHostingLatencies latencies, BattleDelegate6 callback);

Parameters:

ParamTypeDescription
latenciesDSHostingLatenciesThe custom latencies to set for DS hosting data centers.
callbackBattleDelegate6

Return: void

Event Details

OnLatencyTestRoundCompleted

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

/// <summary>The event will be triggered when a round of latency testing is completed.</summary>
public event BattleDelegate7 OnLatencyTestRoundCompleted;

Type Reference:

All Delegates

public delegate void BattleDelegate0(PgosResult a0, BattleListInfo a1);
public delegate void BattleDelegate1(PgosResult a0, BattleBriefListInfo a1);
public delegate void BattleDelegate2(PgosResult a0, BattleDataInfo a1);
public delegate void BattleDelegate3(PgosResult a0, BattleDetailInfo a1);
public delegate void BattleDelegate4(PgosResult a0, PlayerBattleSessionInfo a1);
public delegate void BattleDelegate5(PgosResult a0, DescribeBattleSessionsResult a1);
public delegate void BattleDelegate6(PgosResult a0);
public delegate void BattleDelegate7(LatencyTestRoundCompletedEvt a0);

Type Reference: