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
| API | Description |
|---|---|
| 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. |
| 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. |
| 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. |
| 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. |
| 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. |
| DescribeP2PPlayerBattleSessions | NOTE: This interface can only called by HOST client. Query players session for a battle session. |
| DescribeP2PBattleSessions | Get a list of the P2P battle sessions that the player is participating in. |
| 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. |
| 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. |
| 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. |
Event List
| Event | Description |
|---|---|
| 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. |
| 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. |
| 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. |
| OnP2PBattleSessionUpdated | The 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.
/**
* 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.
*
* @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 ActivateP2PBattleSession(
const FPgosClientActivateP2PBattleSessionParams& Params,
TFunction<void(const FPgosResult& Ret)> ResultCallback) const;
Parameters:
| Param | Type | Description |
|---|---|---|
| Params | const FPgosClientActivateP2PBattleSessionParams& | |
| 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
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.
/**
* 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.
*
* @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 TerminateP2PBattleSession(
const FPgosClientTerminateP2PBattleSessionParams& Params,
TFunction<void(const FPgosResult& Ret)> ResultCallback) const;
Parameters:
| Param | Type | Description |
|---|---|---|
| Params | const FPgosClientTerminateP2PBattleSessionParams& | |
| 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
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.
/**
* 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.
*
* @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 AcceptP2PPlayerBattleSession(
const FPgosClientAcceptP2PPlayerBattleSessionParams& Params,
TFunction<void(const FPgosResult& Ret)> ResultCallback) const;
Parameters:
| Param | Type | Description |
|---|---|---|
| Params | const FPgosClientAcceptP2PPlayerBattleSessionParams& | |
| 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
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.
/**
* 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.
*
* @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 DisconnectP2PPlayerBattleSession(
const FPgosClientDisconnectP2PPlayerBattleSessionParams& Params,
TFunction<void(const FPgosResult& Ret)> ResultCallback) const;
Parameters:
| Param | Type | Description |
|---|---|---|
| Params | const FPgosClientDisconnectP2PPlayerBattleSessionParams& | |
| 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
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.
/**
* 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.
*
* @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 RemoveP2PPlayerBattleSession(
const FPgosClientRemoveP2PPlayerBattleSessionParams& Params,
TFunction<void(const FPgosResult& Ret)> ResultCallback) const;
Parameters:
| Param | Type | Description |
|---|---|---|
| Params | const FPgosClientRemoveP2PPlayerBattleSessionParams& | |
| 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
DescribeP2PPlayerBattleSessions
NOTE: This interface can only called by HOST client. Query players session for a battle session.
/**
* NOTE: This interface can only called by HOST client.
* Query players session for a battle session.
*
* @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 DescribeP2PPlayerBattleSessions(
const FPgosClientDescribeP2PPlayerBattleSessionsParams& Params,
TFunction<void(const FPgosResult& Ret, const FPgosClientDescribeP2PPlayerBattleSessionsResult* Data)> ResultCallback) const;
Parameters:
| Param | Type | Description |
|---|---|---|
| Params | const FPgosClientDescribeP2PPlayerBattleSessionsParams& | |
| ResultCallback | TFunction<void(const FPgosResult& Ret, const FPgosClientDescribeP2PPlayerBattleSessionsResult* 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
DescribeP2PBattleSessions
Get a list of the P2P battle sessions that the player is participating in.
/**
* Get a list of the P2P battle sessions 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 DescribeP2PBattleSessions(
TFunction<void(const FPgosResult& Ret, const FPgosClientDescribeP2PBattleSessionsResult* Data)> ResultCallback) const;
Parameters:
| Param | Type | Description |
|---|---|---|
| ResultCallback | TFunction<void(const FPgosResult& Ret, const FPgosClientDescribeP2PBattleSessionsResult* 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
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.
/**
* 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.
*
* @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 TerminateP2PPlayerBattleSession(
const FPgosClientTerminateP2PPlayerBattleSessionParams& Params,
TFunction<void(const FPgosResult& Ret)> ResultCallback) const;
Parameters:
| Param | Type | Description |
|---|---|---|
| Params | const FPgosClientTerminateP2PPlayerBattleSessionParams& | |
| 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
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.
/**
* 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.
*
* @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 ReportHostHealth(
const FPgosClientReportHostHealthParams& Params,
TFunction<void(const FPgosResult& Ret)> ResultCallback) const;
Parameters:
| Param | Type | Description |
|---|---|---|
| Params | const FPgosClientReportHostHealthParams& | |
| 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
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.
/**
* The client elected as the new host calls this interface to reject the host identity. The current battle session will terminate after this call.
*
* @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 RejectHostMigrating(
const FString& BattleSessionId,
TFunction<void(const FPgosResult& Ret)> ResultCallback) const;
Parameters:
| Param | Type | Description |
|---|---|---|
| BattleSessionId | const FString& | |
| 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
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.
/**
* 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.
*
* @param Event Event result.
*/
DECLARE_MULTICAST_DELEGATE_OneParam(FOnStartP2PBattleSession, const FPgosClientStartP2PBattleSessionEvt& /*Event*/);
FOnStartP2PBattleSession& OnStartP2PBattleSession() { return StartP2PBattleSessionDelegate; }
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.
/**
* 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.
*
* @param Event Event result.
*/
DECLARE_MULTICAST_DELEGATE_OneParam(FOnP2PBattleSessionTerminate, const FPgosClientP2PBattleSessionTerminateEvt& /*Event*/);
FOnP2PBattleSessionTerminate& OnP2PBattleSessionTerminate() { return P2PBattleSessionTerminateDelegate; }
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.
/**
* 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.
*
* @param Event Event result.
*/
DECLARE_MULTICAST_DELEGATE_OneParam(FOnP2PPlayerBattleSessionsTerminated, const FPgosClientP2PPlayerBattleSessionsTerminatedEvt& /*Event*/);
FOnP2PPlayerBattleSessionsTerminated& OnP2PPlayerBattleSessionsTerminated() { return P2PPlayerBattleSessionsTerminatedDelegate; }
Type Reference:
OnP2PBattleSessionUpdated
The event will be triggered when battle session status or player battle session of current player status updated.
/**
* OnP2PBattleSessionUpdated:
* The event will be triggered when battle session status or player battle session of current player status updated.
*
* @param Event Event result.
*/
DECLARE_MULTICAST_DELEGATE_OneParam(FOnP2PBattleSessionUpdated, const FPgosClientP2PBattleSessionUpdatedEvt& /*Event*/);
FOnP2PBattleSessionUpdated& OnP2PBattleSessionUpdated() { return P2PBattleSessionUpdatedDelegate; }
Type Reference: