Quantum 3 3.0.5

Public Member Functions | Public Attributes | List of all members
Photon.Deterministic.Server.DeterministicServer Class Reference

The Quantum server class. Override virtual methods to extend its functionality. More...

Public Member Functions

bool CanSendInput (Int32 player, int tick)
 Prevent sending input for slots that just disconnected (previous player) More...
 
void Close ()
 Called by the plugin before the plugin is destroyed and the room closed. More...
 
void DisconnectClient (DeterministicPluginClient client, String message)
 Disconnect a client. More...
 
void GetActorIds (List< Int32 > actorIds)
 Fill a list of all actor ids. More...
 
Int32 GetClientActorId (int playerIndex)
 Map a player index to an actor id. More...
 
Int32 GetClientActorId (String clientId)
 Map a client id to an Photon actor id. More...
 
DeterministicPluginClient GetClientForActor (Int32 actorNr)
 Retrieve the client object by actor number. More...
 
DeterministicPluginClient GetClientForPlayer (PlayerRef player)
 Retrieve the client object by player ref. Can be null if the client disconnected. More...
 
DeterministicPluginClient GetClientForUser (string userId)
 Retrieve client object by user id. More...
 
void GetClientIds (List< string > clientIds)
 Retrieve a list of all client ids. More...
 
Boolean IsRealPlayer (Int32 playerIndex, int tick)
 Check if the player index is valid and has or ever had a client connected. More...
 
Int32 MaxPing ()
 Get the largest ping (Rtt) of all players. More...
 
virtual void OnDeltaCompressedInput (int tick, byte[] data)
 This callback is invoked when the delta compressed input if finalized and can be used to stream the replay. More...
 
virtual void OnDeterministicClientJoinedSession (DeterministicPluginClient client)
 This method is not invoked anymore. More...
 
virtual Boolean OnDeterministicClientJoinRequestSession (DeterministicPluginClient client, Protocol.Join joinData)
 This method is not invoked anymore. An equivalent would be OnDeterministicStartRequest(DeterministicPluginClient, Protocol.StartRequest). More...
 
virtual Boolean OnDeterministicCommand (DeterministicPluginClient client, Protocol.Command cmd)
 Is called before a player command issues by a client it applied to the simulation. This method can be deferred by returning false and calling SendDeterministicCommand(Protocol.Command) later. More...
 
virtual void OnDeterministicGameConfigs (ref byte[] runtimeConfig, ref DeterministicSessionConfig sessionConfig)
 The callback is called once just before the server starts the Quantum simulation. This is the last time that RuntimeConfig and/or SessionConfig can be changed and overwritten. Both configs passed here have values that were originally send either by a client or a webhook. More...
 
virtual void OnDeterministicInputConfirmed (DeterministicPluginClient client, Int32 tick, Int32 playerIndex, DeterministicTickInput input)
 Is called when input for a client and tick is confirmed. More...
 
virtual void OnDeterministicInputReceived (DeterministicPluginClient client, DeterministicTickInput input)
 Is called then input is received from a client (input is still acceptable based on the time) and also when the server generated the input. More...
 
virtual ? int OnDeterministicLateStart (DeterministicPluginClient client, Protocol.SimulationStart startData)
 Is called when a late-joining or reconnecting client is about to receive the simulation start event. More...
 
virtual void OnDeterministicPlayerAdd (DeterministicPluginClient client, int playerSlot, ref byte[] runtimePlayer)
 Is called before runtime player data for a client is processed after the client sent it or the webhook (if enabled) return it. The runtimePlayer data can be changed in this callback. More...
 
virtual Boolean OnDeterministicPlayerDataSet (DeterministicPluginClient client, Protocol.AddPlayer playerData)
 Has been replaced by OnDeterministicPlayerAdd(DeterministicPluginClient, int, ref byte[]) More...
 
virtual void OnDeterministicPlayerRemove (DeterministicPluginClient client, int playerSlot)
 Is called when a client sends a remove player operation. More...
 
virtual bool OnDeterministicRuntimeConfig (DeterministicPluginClient client, Protocol.RuntimeConfig configData)
 This method is not invoked anymore. Use OnDeterministicGameConfigs(ref byte[], ref DeterministicSessionConfig)"/>. More...
 
virtual void OnDeterministicServerClose ()
 Is called when the room is closed and the server shuts down. More...
 
virtual Boolean OnDeterministicServerInput (DeterministicTickInput input)
 Override to set the input data for a server controlled player. Tick and player index have already been set on the input object. DeterministicInputFlags.PlayerNotPresent is always applied to to the input.Flags after this callback. More...
 
virtual void OnDeterministicServerReplacedInput (DeterministicTickInput input)
 Is called when the input for a real player has been replaced by the server. More...
 
virtual void OnDeterministicServerSetup (IHost host, IEventSender eventSender, IWebhookHost webhookHost, Dictionary< string, string > config, ref Boolean runServerSimulation)
 Is called when the server object is initialized by the plugin. More...
 
virtual bool OnDeterministicSessionCanStart ()
 Is polled repeatedly before the Quantum session is stated until true is returned. More...
 
virtual bool OnDeterministicSessionConfig (DeterministicPluginClient client, Protocol.SessionConfig configData)
 This method is not invoked anymore. Use OnDeterministicGameConfigs(ref byte[], ref DeterministicSessionConfig). More...
 
virtual Boolean OnDeterministicSnapshotRequested (ref Int32 tick, ref byte[] data)
 This callback is called when a late-joining or reconnecting client request a snapshot before the request is forwarded to other clients. When running server simulation the snapshot is send directly in the default implementation of this method. Overload to change the behaviour. More...
 
virtual Boolean OnDeterministicStartRequest (DeterministicPluginClient client, Protocol.StartRequest startRequestData)
 Is called before a client is permitted to request the start of the simulation. More...
 
virtual void OnDeterministicStartSession ()
 Is called when the simulation has been started. More...
 
virtual void OnDeterministicUpdate ()
 Is called for running sessions during each server update after the input has been processed and the server simulation (if any) was processed. More...
 
void SendDeterministicCommand (Protocol.Command command)
 Call this method to inject a command into the simulation from the server. More...
 
void SetDeterministicPlayerData (DeterministicPluginClient client, Protocol.AddPlayer playerData)
 This method has been made obsolete by the internal webhook system. More...
 
void SetDeterministicRuntimeConfig (Byte[] configData)
 Securing RuntimeConfig should be done via webhook or from OnDeterministicGameConfigs(ref byte[], ref DeterministicSessionConfig)"/> More...
 
void SetDeterministicSessionConfig (DeterministicSessionConfig config)
 Securing SessionConfig should be done via webhook or from OnDeterministicGameConfigs(ref byte[], ref DeterministicSessionConfig)"/> More...
 
void SetGameConfigs (byte[] runtimeConfig, object sessionConfig)
 Sets the game configs used for the session. This method is used for webhooks inside the DeterministicPlugin library. To overwrite game configs in the custom plugin SDK use OnDeterministicGameConfigs(ref byte[], ref DeterministicSessionConfig) instead. Will not overwrite configs that were set by other means before. The server will try to progress from Idle to Ready state if possible. More...
 
void SetPlayerData (int actorNr, string userId, byte[] runtimePlayer)
 Sets clients binary RuntimePlayer that will overwrite the data sent by it during the AddPlayer operation. This is called during Join webhook for example. Only works for the first slot of a client (slot=0) and only if the slot hat not been assigned yet. More...
 
void SetPlayerData (int actorNr, string userId, PlayerData playerData)
 Sets the max players slots a client can request. More...
 
void SetServerData (ServerData severData)
 Late configuration data from the plugin to the server class. E.g. data arriving from a webhook. More...
 

Public Attributes

int ClientInputExceptionTolerance = 2
 The number of times clients can cause an input deserialization exception before getting disconnected. Initially set by dashboard value "ClientInputExceptionTolerance". Default is 2. More...
 
IEnumerable< DeterministicPluginClientClients => _clients
 Access the connected client objects. More...
 
int ClientsCount => _clients.Count
 Number of clients connected and registered by the plugin. Corresponds to the number of Clients. More...
 
Int32 PlayerCount => _session.SessionConfig == null ? 0 : _session.SessionConfig.PlayerCount
 Quantum player count as set in DeterministicSessionConfig.PlayerCount. May return 0 while the DeterministicPluginSession.SessionConfig has not been yet confirmed and set. More...
 
IHost PluginHost => _host
 Access the plugin host object More...
 
DeterministicReplayStreaming ReplayStreaming => _replayStreaming
 Access the replay streaming to send final chunk. More...
 
DeterministicPluginSession Session => _session
 Access the current running session. More...
 
IDeterministicSessionContext SessionContext => _sessionContext
 Access to session context including command serializer and resource manager. More...
 
IDeterministicSessionRunner SessionRunner => _sessionRunner
 Grants access to the server simulation that can be casted into QuantumServerSimulation object. More...
 

Detailed Description

The Quantum server class. Override virtual methods to extend its functionality.

Member Function Documentation

◆ OnDeterministicServerSetup()

virtual void Photon.Deterministic.Server.DeterministicServer.OnDeterministicServerSetup ( IHost  host,
IEventSender  eventSender,
IWebhookHost  webhookHost,
Dictionary< string, string >  config,
ref Boolean  runServerSimulation 
)
inlinevirtual

Is called when the server object is initialized by the plugin.

Parameters
hostThe plugin object
eventSenderThe event sender object
webhookHostThe webhook api object
configThe dashboard configuration dictionary
runServerSimulationFinal control to run or skip the server simulation. Ignores the setting when no session runner was passed in the constructor. ///

◆ OnDeterministicServerClose()

virtual void Photon.Deterministic.Server.DeterministicServer.OnDeterministicServerClose ( )
inlinevirtual

Is called when the room is closed and the server shuts down.

◆ OnDeterministicStartRequest()

virtual Boolean Photon.Deterministic.Server.DeterministicServer.OnDeterministicStartRequest ( DeterministicPluginClient  client,
Protocol.StartRequest  startRequestData 
)
inlinevirtual

Is called before a client is permitted to request the start of the simulation.

Parameters
clientClient object
startRequestDataJoin message data
Returns
true to let the client request the start, false to disconnect.

◆ OnDeterministicGameConfigs()

virtual void Photon.Deterministic.Server.DeterministicServer.OnDeterministicGameConfigs ( ref byte[]  runtimeConfig,
ref DeterministicSessionConfig  sessionConfig 
)
inlinevirtual

The callback is called once just before the server starts the Quantum simulation. This is the last time that RuntimeConfig and/or SessionConfig can be changed and overwritten. Both configs passed here have values that were originally send either by a client or a webhook.

Parameters
runtimeConfigRuntimeConfig in bytes
sessionConfigSessionConfig object

◆ OnDeterministicPlayerAdd()

virtual void Photon.Deterministic.Server.DeterministicServer.OnDeterministicPlayerAdd ( DeterministicPluginClient  client,
int  playerSlot,
ref byte[]  runtimePlayer 
)
inlinevirtual

Is called before runtime player data for a client is processed after the client sent it or the webhook (if enabled) return it. The runtimePlayer data can be changed in this callback.

Parameters
clientClient object
playerSlotPlayer slot
runtimePlayerRuntime player object

◆ OnDeterministicPlayerRemove()

virtual void Photon.Deterministic.Server.DeterministicServer.OnDeterministicPlayerRemove ( DeterministicPluginClient  client,
int  playerSlot 
)
inlinevirtual

Is called when a client sends a remove player operation.

Parameters
clientClient object
playerSlotPlayer slot

◆ OnDeterministicSnapshotRequested()

virtual Boolean Photon.Deterministic.Server.DeterministicServer.OnDeterministicSnapshotRequested ( ref Int32  tick,
ref byte[]  data 
)
inlinevirtual

This callback is called when a late-joining or reconnecting client request a snapshot before the request is forwarded to other clients. When running server simulation the snapshot is send directly in the default implementation of this method. Overload to change the behaviour.

Parameters
tickThe tick of the snapshot
dataThe serialized snapshot
Returns
true to signal that parameters have been set and the snapshot can be send directly.

◆ OnDeterministicCommand()

virtual Boolean Photon.Deterministic.Server.DeterministicServer.OnDeterministicCommand ( DeterministicPluginClient  client,
Protocol.Command  cmd 
)
inlinevirtual

Is called before a player command issues by a client it applied to the simulation. This method can be deferred by returning false and calling SendDeterministicCommand(Protocol.Command) later.

Parameters
clientClient that sent the command
cmdCommand object
Returns
true to continue processing the command

◆ OnDeterministicLateStart()

virtual ? int Photon.Deterministic.Server.DeterministicServer.OnDeterministicLateStart ( DeterministicPluginClient  client,
Protocol.SimulationStart  startData 
)
inlinevirtual

Is called when a late-joining or reconnecting client is about to receive the simulation start event.

Parameters
clientClient object
startDataSimulationStart message include serialized runtime config
Returns
Return a value to force a certain tick that the player should start from

◆ OnDeterministicInputReceived()

virtual void Photon.Deterministic.Server.DeterministicServer.OnDeterministicInputReceived ( DeterministicPluginClient  client,
DeterministicTickInput  input 
)
inlinevirtual

Is called then input is received from a client (input is still acceptable based on the time) and also when the server generated the input.

Parameters
clientClient object
inputInput object

◆ OnDeterministicInputConfirmed()

virtual void Photon.Deterministic.Server.DeterministicServer.OnDeterministicInputConfirmed ( DeterministicPluginClient  client,
Int32  tick,
Int32  playerIndex,
DeterministicTickInput  input 
)
inlinevirtual

Is called when input for a client and tick is confirmed.

Parameters
clientClient object
tickThe input tick
playerIndexPlayer index
inputInput object

◆ OnDeterministicServerInput()

virtual Boolean Photon.Deterministic.Server.DeterministicServer.OnDeterministicServerInput ( DeterministicTickInput  input)
inlinevirtual

Override to set the input data for a server controlled player. Tick and player index have already been set on the input object. DeterministicInputFlags.PlayerNotPresent is always applied to to the input.Flags after this callback.

Parameters
inputInput data
Returns
true when the input is modified in this callback

◆ OnDeterministicServerReplacedInput()

virtual void Photon.Deterministic.Server.DeterministicServer.OnDeterministicServerReplacedInput ( DeterministicTickInput  input)
inlinevirtual

Is called when the input for a real player has been replaced by the server.

Parameters
inputInput object

◆ OnDeterministicSessionCanStart()

virtual bool Photon.Deterministic.Server.DeterministicServer.OnDeterministicSessionCanStart ( )
inlinevirtual

Is polled repeatedly before the Quantum session is stated until true is returned.

Returns
true to commence the session start or false to delay it.

◆ OnDeterministicStartSession()

virtual void Photon.Deterministic.Server.DeterministicServer.OnDeterministicStartSession ( )
inlinevirtual

Is called when the simulation has been started.

◆ OnDeterministicUpdate()

virtual void Photon.Deterministic.Server.DeterministicServer.OnDeterministicUpdate ( )
inlinevirtual

Is called for running sessions during each server update after the input has been processed and the server simulation (if any) was processed.

◆ OnDeltaCompressedInput()

virtual void Photon.Deterministic.Server.DeterministicServer.OnDeltaCompressedInput ( int  tick,
byte[]  data 
)
inlinevirtual

This callback is invoked when the delta compressed input if finalized and can be used to stream the replay.

Parameters
tickTick
dataDelta compressed input for one tick

◆ SendDeterministicCommand()

void Photon.Deterministic.Server.DeterministicServer.SendDeterministicCommand ( Protocol.Command  command)
inline

Call this method to inject a command into the simulation from the server.

Parameters
commandCommand object

◆ SetDeterministicPlayerData()

void Photon.Deterministic.Server.DeterministicServer.SetDeterministicPlayerData ( DeterministicPluginClient  client,
Protocol.AddPlayer  playerData 
)
inline

This method has been made obsolete by the internal webhook system.

◆ SetDeterministicSessionConfig()

void Photon.Deterministic.Server.DeterministicServer.SetDeterministicSessionConfig ( DeterministicSessionConfig  config)
inline

Securing SessionConfig should be done via webhook or from OnDeterministicGameConfigs(ref byte[], ref DeterministicSessionConfig)"/>

◆ SetDeterministicRuntimeConfig()

void Photon.Deterministic.Server.DeterministicServer.SetDeterministicRuntimeConfig ( Byte[]  configData)
inline

Securing RuntimeConfig should be done via webhook or from OnDeterministicGameConfigs(ref byte[], ref DeterministicSessionConfig)"/>

◆ OnDeterministicPlayerDataSet()

virtual Boolean Photon.Deterministic.Server.DeterministicServer.OnDeterministicPlayerDataSet ( DeterministicPluginClient  client,
Protocol.AddPlayer  playerData 
)
inlinevirtual

Has been replaced by OnDeterministicPlayerAdd(DeterministicPluginClient, int, ref byte[])

◆ OnDeterministicClientJoinRequestSession()

virtual Boolean Photon.Deterministic.Server.DeterministicServer.OnDeterministicClientJoinRequestSession ( DeterministicPluginClient  client,
Protocol.Join  joinData 
)
inlinevirtual

This method is not invoked anymore. An equivalent would be OnDeterministicStartRequest(DeterministicPluginClient, Protocol.StartRequest).

◆ OnDeterministicClientJoinedSession()

virtual void Photon.Deterministic.Server.DeterministicServer.OnDeterministicClientJoinedSession ( DeterministicPluginClient  client)
inlinevirtual

This method is not invoked anymore.

◆ OnDeterministicSessionConfig()

virtual bool Photon.Deterministic.Server.DeterministicServer.OnDeterministicSessionConfig ( DeterministicPluginClient  client,
Protocol.SessionConfig  configData 
)
inlinevirtual

This method is not invoked anymore. Use OnDeterministicGameConfigs(ref byte[], ref DeterministicSessionConfig).

◆ OnDeterministicRuntimeConfig()

virtual bool Photon.Deterministic.Server.DeterministicServer.OnDeterministicRuntimeConfig ( DeterministicPluginClient  client,
Protocol.RuntimeConfig  configData 
)
inlinevirtual

This method is not invoked anymore. Use OnDeterministicGameConfigs(ref byte[], ref DeterministicSessionConfig)"/>.

◆ Close()

void Photon.Deterministic.Server.DeterministicServer.Close ( )
inline

Called by the plugin before the plugin is destroyed and the room closed.

◆ SetPlayerData() [1/2]

void Photon.Deterministic.Server.DeterministicServer.SetPlayerData ( int  actorNr,
string  userId,
byte[]  runtimePlayer 
)
inline

Sets clients binary RuntimePlayer that will overwrite the data sent by it during the AddPlayer operation. This is called during Join webhook for example. Only works for the first slot of a client (slot=0) and only if the slot hat not been assigned yet.

Parameters
actorNrClient Photon actor number
userIdPhoton user id
runtimePlayerBinary RuntimePlayer

◆ SetPlayerData() [2/2]

void Photon.Deterministic.Server.DeterministicServer.SetPlayerData ( int  actorNr,
string  userId,
PlayerData  playerData 
)
inline

Sets the max players slots a client can request.

Parameters
actorNrPhoton Actor id
userIdPhoton user id
playerDataAdditional player data used by the server.

◆ SetServerData()

void Photon.Deterministic.Server.DeterministicServer.SetServerData ( ServerData  severData)
inline

Late configuration data from the plugin to the server class. E.g. data arriving from a webhook.

Parameters
severDataServer configuration data to process.

◆ SetGameConfigs()

void Photon.Deterministic.Server.DeterministicServer.SetGameConfigs ( byte[]  runtimeConfig,
object  sessionConfig 
)
inline

Sets the game configs used for the session. This method is used for webhooks inside the DeterministicPlugin library. To overwrite game configs in the custom plugin SDK use OnDeterministicGameConfigs(ref byte[], ref DeterministicSessionConfig) instead. Will not overwrite configs that were set by other means before. The server will try to progress from Idle to Ready state if possible.

Parameters
runtimeConfigBinary RuntimePlayer
sessionConfigSessionConfig as object (original type has to be DeterministicSessionConfig)

◆ MaxPing()

Int32 Photon.Deterministic.Server.DeterministicServer.MaxPing ( )
inline

Get the largest ping (Rtt) of all players.

Returns
Max ping in milliseconds

◆ DisconnectClient()

void Photon.Deterministic.Server.DeterministicServer.DisconnectClient ( DeterministicPluginClient  client,
String  message 
)
inline

Disconnect a client.

Parameters
clientClient object
messageDisconnect message

◆ GetClientIds()

void Photon.Deterministic.Server.DeterministicServer.GetClientIds ( List< string >  clientIds)
inline

Retrieve a list of all client ids.

Parameters
clientIdsList that is filled with DeterministicPluginClient.ClientId

◆ GetActorIds()

void Photon.Deterministic.Server.DeterministicServer.GetActorIds ( List< Int32 >  actorIds)
inline

Fill a list of all actor ids.

◆ GetClientActorId() [1/2]

Int32 Photon.Deterministic.Server.DeterministicServer.GetClientActorId ( String  clientId)
inline

Map a client id to an Photon actor id.

Parameters
clientIdClient id
Returns
Actor id

◆ GetClientActorId() [2/2]

Int32 Photon.Deterministic.Server.DeterministicServer.GetClientActorId ( int  playerIndex)
inline

Map a player index to an actor id.

Parameters
playerIndex
Returns
Actor id

◆ IsRealPlayer()

Boolean Photon.Deterministic.Server.DeterministicServer.IsRealPlayer ( Int32  playerIndex,
int  tick 
)
inline

Check if the player index is valid and has or ever had a client connected.

Parameters
playerIndexPlayer index
tickThe tick is used to exclude freshly disconnected players.
Returns
true is the player is a valid and is backed by a client.

◆ CanSendInput()

bool Photon.Deterministic.Server.DeterministicServer.CanSendInput ( Int32  player,
int  tick 
)
inline

Prevent sending input for slots that just disconnected (previous player)

◆ GetClientForActor()

DeterministicPluginClient Photon.Deterministic.Server.DeterministicServer.GetClientForActor ( Int32  actorNr)
inline

Retrieve the client object by actor number.

Parameters
actorNrActor id
Returns
Client object or null

◆ GetClientForUser()

DeterministicPluginClient Photon.Deterministic.Server.DeterministicServer.GetClientForUser ( string  userId)
inline

Retrieve client object by user id.

Parameters
userIdUser id.
Returns
Client object or null

◆ GetClientForPlayer()

DeterministicPluginClient Photon.Deterministic.Server.DeterministicServer.GetClientForPlayer ( PlayerRef  player)
inline

Retrieve the client object by player ref. Can be null if the client disconnected.

Parameters
playerPlayer ref
Returns
Client object representing that player or null if not present or in use.

Member Data Documentation

◆ SessionContext

IDeterministicSessionContext Photon.Deterministic.Server.DeterministicServer.SessionContext => _sessionContext

Access to session context including command serializer and resource manager.

◆ SessionRunner

IDeterministicSessionRunner Photon.Deterministic.Server.DeterministicServer.SessionRunner => _sessionRunner

Grants access to the server simulation that can be casted into QuantumServerSimulation object.

◆ PlayerCount

Int32 Photon.Deterministic.Server.DeterministicServer.PlayerCount => _session.SessionConfig == null ? 0 : _session.SessionConfig.PlayerCount

Quantum player count as set in DeterministicSessionConfig.PlayerCount. May return 0 while the DeterministicPluginSession.SessionConfig has not been yet confirmed and set.

◆ Session

DeterministicPluginSession Photon.Deterministic.Server.DeterministicServer.Session => _session

Access the current running session.

◆ Clients

IEnumerable<DeterministicPluginClient> Photon.Deterministic.Server.DeterministicServer.Clients => _clients

Access the connected client objects.

◆ ClientsCount

int Photon.Deterministic.Server.DeterministicServer.ClientsCount => _clients.Count

Number of clients connected and registered by the plugin. Corresponds to the number of Clients.

◆ ClientInputExceptionTolerance

int Photon.Deterministic.Server.DeterministicServer.ClientInputExceptionTolerance = 2

The number of times clients can cause an input deserialization exception before getting disconnected. Initially set by dashboard value "ClientInputExceptionTolerance". Default is 2.

◆ ReplayStreaming

DeterministicReplayStreaming Photon.Deterministic.Server.DeterministicServer.ReplayStreaming => _replayStreaming

Access the replay streaming to send final chunk.

◆ PluginHost

IHost Photon.Deterministic.Server.DeterministicServer.PluginHost => _host

Access the plugin host object