Skip to main content

Client P2PBattle API Reference

Unlike online battle sessions, PGOS manages P2P battle sessions through game clients instead of dedicated servers or local dedicated servers.

API List

APIDescription
ActivateP2PBattleSessionNOTE: This interface can only called by HOST client. Activate a P2P battle session. Signal PGOS that the host is ready for clients to connect.
TerminateP2PBattleSessionNOTE: This interface can only called by HOST client. Terminate a P2P battle session. This method should be called when a P2P game is(or will) end.
AcceptP2PPlayerBattleSessionNOTE: This interface can only called by HOST client. Validates a player session, and signal PGOS to update player session's status to Active. This method should be called when a client requests a connection to the server.
DisconnectP2PPlayerBattleSessionNOTE: This interface can only called by HOST client. Turn a player session status to Disconnected.You can call this interface when the player disconnects from DS non-permanently. The player session can be resumed to Active at any time by calling the AcceptPlayerBattleSession interface again.
RemoveP2PPlayerBattleSessionNOTE: This interface can only called by HOST client. Turn a player session status to Completed.You should call this interface when a player. This interface will set the player session to a final state and cannot be restored.
DescribeP2PPlayerBattleSessionsNOTE: This interface can only called by HOST client. Query players session for a battle session.
DescribeP2PBattleSessionsGet a list of the P2P battle sessions that the player is participating in.
TerminateP2PPlayerBattleSessionTry to terminate the player session in a P2P battle. The player session status will turn to Completed after interface is called. This interface should be called when the player wants to leave the battle session.
ReportHostHealthP2P clients can use this interface to report the health status of a host to PGOS. Note that calls originating from the host itself will be ignored.
RejectHostMigratingThe client elected as the new host calls this interface to reject the host identity. The current battle session will terminate after this call.

Event List

EventDescription
OnStartP2PBattleSessionNOTE: This event is for HOST client only. The event will be triggered when a new P2P battle session is assigned to this client.
OnP2PBattleSessionTerminateNOTE: This event is for HOST client only. The event will be triggered once the P2P battle session being terminated from admin portal. Game server should call TerminateP2PBattleSession. Otherwise, the session will be reclaimed by PGOS after 5 minutes.
OnP2PPlayerBattleSessionsTerminatedThis event will be triggered in the following two situations: 1. The game client calls the TerminateP2PPlayerBattleSession interface, and the event is triggered in the host. 2. The host calls the TerminateP2PBattleSession interface, and the event is triggered in the game client.
OnP2PBattleSessionUpdatedThe event will be triggered when battle session status or player battle session of current player status updated.

API Details

ActivateP2PBattleSession

NOTE: This interface can only called by HOST client. Activate a P2P battle session. Signal PGOS that the host is ready for clients to connect.

/// <summary>
/// NOTE: This interface can only called by HOST client.
/// Activate a P2P battle session. Signal PGOS that the host is ready for clients to connect.
/// </summary>
public void ActivateP2PBattleSession(ActivateP2PBattleSessionParams pgos_params, P2PBattleDelegate0 callback);

Parameters:

ParamTypeDescription
pgos_paramsActivateP2PBattleSessionParams
callbackP2PBattleDelegate0

Return: void

TerminateP2PBattleSession

NOTE: This interface can only called by HOST client. Terminate a P2P battle session. This method should be called when a P2P game is(or will) end.

/// <summary>
/// NOTE: This interface can only called by HOST client.
/// Terminate a P2P battle session.
/// This method should be called when a P2P game is(or will) end.
/// </summary>
public void TerminateP2PBattleSession(TerminateP2PBattleSessionParams pgos_params, P2PBattleDelegate0 callback);

Parameters:

ParamTypeDescription
pgos_paramsTerminateP2PBattleSessionParams
callbackP2PBattleDelegate0

Return: void

AcceptP2PPlayerBattleSession

NOTE: This interface can only called by HOST client. Validates a player session, and signal PGOS to update player session's status to Active. This method should be called when a client requests a connection to the server.

/// <summary>
/// NOTE: This interface can only called by HOST client.
/// Validates a player session, and signal PGOS to update player session's status to Active.
/// This method should be called when a client requests a connection to the server.
/// </summary>
public void AcceptP2PPlayerBattleSession(AcceptP2PPlayerBattleSessionParams pgos_params, P2PBattleDelegate0 callback);

Parameters:

ParamTypeDescription
pgos_paramsAcceptP2PPlayerBattleSessionParams
callbackP2PBattleDelegate0

Return: void

DisconnectP2PPlayerBattleSession

NOTE: This interface can only called by HOST client. Turn a player session status to Disconnected.You can call this interface when the player disconnects from DS non-permanently. The player session can be resumed to Active at any time by calling the AcceptPlayerBattleSession interface again.

/// <summary>
/// NOTE: This interface can only called by HOST client.
/// Turn a player session status to Disconnected.You can call this interface when the player disconnects from DS non-permanently.
/// The player session can be resumed to Active at any time by calling the AcceptPlayerBattleSession interface again.
/// </summary>
public void DisconnectP2PPlayerBattleSession(DisconnectP2PPlayerBattleSessionParams pgos_params, P2PBattleDelegate0 callback);

Parameters:

ParamTypeDescription
pgos_paramsDisconnectP2PPlayerBattleSessionParams
callbackP2PBattleDelegate0

Return: void

RemoveP2PPlayerBattleSession

NOTE: This interface can only called by HOST client. Turn a player session status to Completed.You should call this interface when a player. This interface will set the player session to a final state and cannot be restored.

/// <summary>
/// NOTE: This interface can only called by HOST client.
/// Turn a player session status to Completed.You should call this interface when a player.
/// This interface will set the player session to a final state and cannot be restored.
/// </summary>
public void RemoveP2PPlayerBattleSession(RemoveP2PPlayerBattleSessionParams pgos_params, P2PBattleDelegate0 callback);

Parameters:

ParamTypeDescription
pgos_paramsRemoveP2PPlayerBattleSessionParams
callbackP2PBattleDelegate0

Return: void

DescribeP2PPlayerBattleSessions

NOTE: This interface can only called by HOST client. Query players session for a battle session.

/// <summary>
/// NOTE: This interface can only called by HOST client.
/// Query players session for a battle session.
/// </summary>
public void DescribeP2PPlayerBattleSessions(DescribeP2PPlayerBattleSessionsParams pgos_params, P2PBattleDelegate1 callback);

Parameters:

ParamTypeDescription
pgos_paramsDescribeP2PPlayerBattleSessionsParams
callbackP2PBattleDelegate1

Return: void

DescribeP2PBattleSessions

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

/// <summary>Get a list of the P2P battle sessions that the player is participating in.</summary>
public void DescribeP2PBattleSessions(P2PBattleDelegate2 callback);

Parameters:

ParamTypeDescription
callbackP2PBattleDelegate2

Return: void

TerminateP2PPlayerBattleSession

Try to terminate the player session in a P2P battle. The player session status will turn to Completed after interface is called. This interface should be called when the player wants to leave the battle session.

/// <summary>
/// Try to terminate the player session in a P2P battle. The player session status will turn to Completed after interface is called.
/// This interface should be called when the player wants to leave the battle session.
/// </summary>
public void TerminateP2PPlayerBattleSession(TerminateP2PPlayerBattleSessionParams pgos_params, P2PBattleDelegate0 callback);

Parameters:

ParamTypeDescription
pgos_paramsTerminateP2PPlayerBattleSessionParams
callbackP2PBattleDelegate0

Return: void

ReportHostHealth

P2P clients can use this interface to report the health status of a host to PGOS. Note that calls originating from the host itself will be ignored.

/// <summary>P2P clients can use this interface to report the health status of a host to PGOS. Note that calls originating from the host itself will be ignored.</summary>
public void ReportHostHealth(ReportHostHealthParams pgos_params, P2PBattleDelegate0 callback);

Parameters:

ParamTypeDescription
pgos_paramsReportHostHealthParams
callbackP2PBattleDelegate0

Return: void

RejectHostMigrating

The client elected as the new host calls this interface to reject the host identity. The current battle session will terminate after this call.

/// <summary>The client elected as the new host calls this interface to reject the host identity. The current battle session will terminate after this call.</summary>
public void RejectHostMigrating(string battle_session_id, P2PBattleDelegate0 callback);

Parameters:

ParamTypeDescription
battle_session_idstring
callbackP2PBattleDelegate0

Return: void

Event Details

OnStartP2PBattleSession

NOTE: This event is for HOST client only. The event will be triggered when a new P2P battle session is assigned to this client.

/// <summary>
/// NOTE: This event is for HOST client only.
/// The event will be triggered when a new P2P battle session is assigned to this client.
/// </summary>
public event P2PBattleDelegate3 OnStartP2PBattleSession;

Type Reference:

OnP2PBattleSessionTerminate

NOTE: This event is for HOST client only. The event will be triggered once the P2P battle session being terminated from admin portal. Game server should call TerminateP2PBattleSession. Otherwise, the session will be reclaimed by PGOS after 5 minutes.

/// <summary>
/// NOTE: This event is for HOST client only.
/// The event will be triggered once the P2P battle session being terminated from admin portal.
/// Game server should call TerminateP2PBattleSession. Otherwise, the session will be reclaimed by PGOS after 5 minutes.
/// </summary>
public event P2PBattleDelegate4 OnP2PBattleSessionTerminate;

Type Reference:

OnP2PPlayerBattleSessionsTerminated

This event will be triggered in the following two situations: 1. The game client calls the TerminateP2PPlayerBattleSession interface, and the event is triggered in the host. 2. The host calls the TerminateP2PBattleSession interface, and the event is triggered in the game client.

/// <summary>
/// This event will be triggered in the following two situations:
/// 1. The game client calls the TerminateP2PPlayerBattleSession interface, and the event is triggered in the host.
/// 2. The host calls the TerminateP2PBattleSession interface, and the event is triggered in the game client.
/// </summary>
public event P2PBattleDelegate5 OnP2PPlayerBattleSessionsTerminated;

Type Reference:

OnP2PBattleSessionUpdated

The event will be triggered when battle session status or player battle session of current player status updated.

/// <summary>The event will be triggered when battle session status or player battle session of current player status updated.</summary>
public event P2PBattleDelegate6 OnP2PBattleSessionUpdated;

Type Reference:

All Delegates

public delegate void P2PBattleDelegate0(PgosResult a0);
public delegate void P2PBattleDelegate1(PgosResult a0, DescribeP2PPlayerBattleSessionsResult a1);
public delegate void P2PBattleDelegate2(PgosResult a0, DescribeP2PBattleSessionsResult a1);
public delegate void P2PBattleDelegate3(StartP2PBattleSessionEvt a0);
public delegate void P2PBattleDelegate4(P2PBattleSessionTerminateEvt a0);
public delegate void P2PBattleDelegate5(P2PPlayerBattleSessionsTerminatedEvt a0);
public delegate void P2PBattleDelegate6(P2PBattleSessionUpdatedEvt a0);

Type Reference: