Photon Quantum 3.0.0

Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Properties | List of all members
Photon.Deterministic.DeterministicPlugin Class Reference

Override the Quantum plugin class to create a custom server object. More...

Inherits PluginBase, and IHost.

Public Member Functions

 DeterministicPlugin ()
 Create a DeterministicPlugin instance which creates a new instance of Server.DeterministicServer More...
 
 DeterministicPlugin (IServer server)
 Create a DeterministicPlugin instance passing in a server object. More...
 
override void BeforeJoin (IBeforeJoinGameCallInfo info)
 Optionally fires a webhook (WebHooksConfig.EnableOnJoin) and then continue the process with OnBeforeJoinContinue(). The join operation will be on hold (non-blocking) in this case. More...
 
void Disconnect (int actorNr, string message)
 Removed the actor from the plugin host. Is automatically called when the DeterministicServer is closed. More...
 
void LogError (string message)
 Directs log to PluginHost. More...
 
void LogException (Exception exn)
 Directs log to PluginHost. More...
 
void LogException (string message, Exception exn)
 Directs log to PluginHost. More...
 
void LogFatal (string message)
 Directs log to PluginHost. More...
 
void LogInfo (string message)
 Directs log to PluginHost. More...
 
void LogWarning (string message)
 Directs log to PluginHost. More...
 
override void OnCloseGame (ICloseGameCallInfo info)
 Called when the room is closing. The Quantum server is closed right away. When the close webhook is enabled, the processing is halted until a response is completed. More...
 
override void OnCreateGame (ICreateGameCallInfo info)
 Optionally fires a webhook (WebHooksConfig.EnableOnCreate) and then continue the process with OnCreateGameContinue(). The create operation will be on hold (blocking) in this case. LobbyProperties are validated and overwritten. More...
 
override void OnLeave (ILeaveGameCallInfo info)
 Called when an actor leaves the room. Quantum ignores the inactive flag. When enabled a webhook is fired, processing the leave action is never halted, though. More...
 
bool TrySendAddPlayerWebRequest (string userId, int playerSlot, byte[] runtimePlayer, WebhookHostCallbacks.AddRuntimePlayerWebResponse callback)
 Check plugin config for "WebHookEnableRuntimePlayer". If true sends a RuntimePlayer web request. More...
 
bool TrySendGameConfigsWebRequest (string userId, byte[] runtimeConfig, object sessionConfig, WebhookHostCallbacks.SendGameConfigsWebResponse callback)
 Checks the plugin config for "WebHookEnableRuntimeConfig" and tries to send a webhook accordingly. This can be only issued once successfully as internally HasRuntimeConfigWebhookBeenSent is checked. More...
 
bool TrySendPlayerAddedWebRequest (string userId, int playerSlot, int player)
 If "WebHookEnablePlayerAdded" is enabled in the Photon config a fire and forget webrequest is send to a custom backend when a player was successfully added to the Quantum simulation. More...
 
bool TrySendPlayerRemovedWebRequest (string userId, int playerSlot, int player, int playerRemovedReason)
 If "WebHookEnablePlayerRemoved" is enabled in the Photon config a fire and forget webrequest is send to a custom backend when a player was successfully removed to the Quantum simulation. More...
 

Public Attributes

string GameId => PluginHost == null ? string.Empty : PluginHost.GameId
 Returns the room name. More...
 
bool IsClosed => _isClosed
 Returns true when the plugin has been closed. More...
 
override string Name => "QuantumPlugin"
 Plugin name. This will correspond with the plugin name that the client selects when connecting to a room. More...
 
IServer Server => _server
 Server object that the plugin needs as an entry to call rudimentary callbacks. More...
 
string UniqueGameId => _uniqueGameId ?? WebHooksUtil.CreateGameId(this, PluginHost)
 Returns a unique game id, a combination of region, cloud and room name. More...
 

Protected Member Functions

virtual void OnBeforeJoinContinue (JoinQuantumGameResponse response, WebHookError error, IBeforeJoinGameCallInfo info)
 Continuation of the before join operation if a webhook was used. Exceptions thrown will be caught and logged as errors. More...
 
virtual void OnCreateGameContinue (CreateQuantumGameResponse response, WebHookError error, ICreateGameCallInfo info)
 If a webhook is send during CreateGame it will eventually continue here with the response or error. Exceptions thrown will be cached and logged as errors. More...
 
bool TryGetActorNumber (string userId, out int actorNr)
 Search the actor number for a UserId. This may fail. More...
 
bool TryGetUserId (int actorNumber, out string userId)
 Search the Photon user id using a Photon actor id, this may fail. More...
 

Protected Attributes

QuantumWebHooksConfig WebHooksConfig => _webHooksConfig # new QuantumWebHooksConfig()
 Return the current webhook config or lazy initialize a default one. More...
 

Properties

IPhotonDeterministicCounters Counters [get, set]
 Quantum performance counter. Can be null. More...
 
int EmptyRoomTTL [get]
 Retrieve the EmptyRoomTTL value from GameProperties, return 0 when nothing was found. More...
 

Detailed Description

Override the Quantum plugin class to create a custom server object.

Constructor & Destructor Documentation

◆ DeterministicPlugin() [1/2]

Photon.Deterministic.DeterministicPlugin.DeterministicPlugin ( )
inline

Create a DeterministicPlugin instance which creates a new instance of Server.DeterministicServer

◆ DeterministicPlugin() [2/2]

Photon.Deterministic.DeterministicPlugin.DeterministicPlugin ( IServer  server)
inline

Create a DeterministicPlugin instance passing in a server object.

Parameters
serverServer object of type Server.DeterministicServer

Member Function Documentation

◆ OnCreateGame()

override void Photon.Deterministic.DeterministicPlugin.OnCreateGame ( ICreateGameCallInfo  info)
inline

Optionally fires a webhook (WebHooksConfig.EnableOnCreate) and then continue the process with OnCreateGameContinue(). The create operation will be on hold (blocking) in this case. LobbyProperties are validated and overwritten.

Parameters
infoCreate game info object

◆ OnCreateGameContinue()

virtual void Photon.Deterministic.DeterministicPlugin.OnCreateGameContinue ( CreateQuantumGameResponse  response,
WebHookError  error,
ICreateGameCallInfo  info 
)
inlineprotectedvirtual

If a webhook is send during CreateGame it will eventually continue here with the response or error. Exceptions thrown will be cached and logged as errors.

Parameters
responseWill be set if the webhook was successful.
errorWill be set if the webhook was unsuccessful or an error occurred.
infoInfo object to continue or fail the game creation.

◆ BeforeJoin()

override void Photon.Deterministic.DeterministicPlugin.BeforeJoin ( IBeforeJoinGameCallInfo  info)
inline

Optionally fires a webhook (WebHooksConfig.EnableOnJoin) and then continue the process with OnBeforeJoinContinue(). The join operation will be on hold (non-blocking) in this case.

Parameters
infoJoin game info object

◆ OnBeforeJoinContinue()

virtual void Photon.Deterministic.DeterministicPlugin.OnBeforeJoinContinue ( JoinQuantumGameResponse  response,
WebHookError  error,
IBeforeJoinGameCallInfo  info 
)
inlineprotectedvirtual

Continuation of the before join operation if a webhook was used. Exceptions thrown will be caught and logged as errors.

Parameters
responseWill be set if the webhook was successful.
errorWill be set if the webhook was unsuccessful or an error occurred.
infoInfo object to continue or fail the join operation.

◆ TryGetActorNumber()

bool Photon.Deterministic.DeterministicPlugin.TryGetActorNumber ( string  userId,
out int  actorNr 
)
inlineprotected

Search the actor number for a UserId. This may fail.

Parameters
userIdClient User Id
actorNrClient Actor Id
Returns
true if an actor was found for the UserId

◆ TryGetUserId()

bool Photon.Deterministic.DeterministicPlugin.TryGetUserId ( int  actorNumber,
out string  userId 
)
inlineprotected

Search the Photon user id using a Photon actor id, this may fail.

Parameters
actorNumberClient Actor Id
userIdClient User Id
Returns
true if an actor was found for the actor id

◆ OnLeave()

override void Photon.Deterministic.DeterministicPlugin.OnLeave ( ILeaveGameCallInfo  info)
inline

Called when an actor leaves the room. Quantum ignores the inactive flag. When enabled a webhook is fired, processing the leave action is never halted, though.

Parameters
info

◆ OnCloseGame()

override void Photon.Deterministic.DeterministicPlugin.OnCloseGame ( ICloseGameCallInfo  info)
inline

Called when the room is closing. The Quantum server is closed right away. When the close webhook is enabled, the processing is halted until a response is completed.

Parameters
info

◆ LogInfo()

void Photon.Deterministic.DeterministicPlugin.LogInfo ( string  message)
inline

Directs log to PluginHost.

◆ LogFatal()

void Photon.Deterministic.DeterministicPlugin.LogFatal ( string  message)
inline

Directs log to PluginHost.

◆ LogWarning()

void Photon.Deterministic.DeterministicPlugin.LogWarning ( string  message)
inline

Directs log to PluginHost.

◆ LogError()

void Photon.Deterministic.DeterministicPlugin.LogError ( string  message)
inline

Directs log to PluginHost.

◆ LogException() [1/2]

void Photon.Deterministic.DeterministicPlugin.LogException ( Exception  exn)
inline

Directs log to PluginHost.

◆ LogException() [2/2]

void Photon.Deterministic.DeterministicPlugin.LogException ( string  message,
Exception  exn 
)
inline

Directs log to PluginHost.

◆ Disconnect()

void Photon.Deterministic.DeterministicPlugin.Disconnect ( int  actorNr,
string  message 
)
inline

Removed the actor from the plugin host. Is automatically called when the DeterministicServer is closed.

Parameters
actorNrActor Number from DeterministicPluginClient.ActorNr
messageDisconnect message

◆ TrySendAddPlayerWebRequest()

bool Photon.Deterministic.DeterministicPlugin.TrySendAddPlayerWebRequest ( string  userId,
int  playerSlot,
byte[]  runtimePlayer,
WebhookHostCallbacks.AddRuntimePlayerWebResponse  callback 
)
inline

Check plugin config for "WebHookEnableRuntimePlayer". If true sends a RuntimePlayer web request.

Parameters
userIdPhoton user id
playerSlotPlayer index (when one client controls multiple players). Must be set.
runtimePlayerRuntimePlayer in bytes. Can be null according to Webhook API.
callbackCallback to forward the response. Must be set.
Returns
true if webhook was send.

◆ TrySendPlayerAddedWebRequest()

bool Photon.Deterministic.DeterministicPlugin.TrySendPlayerAddedWebRequest ( string  userId,
int  playerSlot,
int  player 
)
inline

If "WebHookEnablePlayerAdded" is enabled in the Photon config a fire and forget webrequest is send to a custom backend when a player was successfully added to the Quantum simulation.

Parameters
userIdPhoton user id
playerSlotLocal player slot
playerGlobal player id
Returns
true if webhook was send.

◆ TrySendPlayerRemovedWebRequest()

bool Photon.Deterministic.DeterministicPlugin.TrySendPlayerRemovedWebRequest ( string  userId,
int  playerSlot,
int  player,
int  playerRemovedReason 
)
inline

If "WebHookEnablePlayerRemoved" is enabled in the Photon config a fire and forget webrequest is send to a custom backend when a player was successfully removed to the Quantum simulation.

Parameters
userIdPhoton user id
playerSlotLocal player slot or -1 if all players
playerGlobal player id or -1 if all players
playerRemovedReasonReason that the player was removed
Returns
true if webhook was send.

◆ TrySendGameConfigsWebRequest()

bool Photon.Deterministic.DeterministicPlugin.TrySendGameConfigsWebRequest ( string  userId,
byte[]  runtimeConfig,
object  sessionConfig,
WebhookHostCallbacks.SendGameConfigsWebResponse  callback 
)
inline

Checks the plugin config for "WebHookEnableRuntimeConfig" and tries to send a webhook accordingly. This can be only issued once successfully as internally HasRuntimeConfigWebhookBeenSent is checked.

Parameters
userIdUser id
runtimeConfigRuntimeConfig from the client. Can be null according to Webhook API.
sessionConfigSessionConfig as DeterministicSessionConfig object from the client. Can be null according to Webhook API.
callbackWebhook callback. Must be set.
Returns
true, if webhook was sent or previously send

Member Data Documentation

◆ Server

IServer Photon.Deterministic.DeterministicPlugin.Server => _server

Server object that the plugin needs as an entry to call rudimentary callbacks.

◆ Name

override string Photon.Deterministic.DeterministicPlugin.Name => "QuantumPlugin"

Plugin name. This will correspond with the plugin name that the client selects when connecting to a room.

RoomOptions roomOptions = new RoomOptions {
Plugins = new string[] { "QuantumPlugin" }
};

◆ UniqueGameId

string Photon.Deterministic.DeterministicPlugin.UniqueGameId => _uniqueGameId ?? WebHooksUtil.CreateGameId(this, PluginHost)

Returns a unique game id, a combination of region, cloud and room name.

◆ GameId

string Photon.Deterministic.DeterministicPlugin.GameId => PluginHost == null ? string.Empty : PluginHost.GameId

Returns the room name.

◆ IsClosed

bool Photon.Deterministic.DeterministicPlugin.IsClosed => _isClosed

Returns true when the plugin has been closed.

◆ WebHooksConfig

QuantumWebHooksConfig Photon.Deterministic.DeterministicPlugin.WebHooksConfig => _webHooksConfig # new QuantumWebHooksConfig()
protected

Return the current webhook config or lazy initialize a default one.

Property Documentation

◆ EmptyRoomTTL

int Photon.Deterministic.DeterministicPlugin.EmptyRoomTTL
get

Retrieve the EmptyRoomTTL value from GameProperties, return 0 when nothing was found.

◆ Counters

IPhotonDeterministicCounters Photon.Deterministic.DeterministicPlugin.Counters
getset

Quantum performance counter. Can be null.