Photon Quantum 2.1.1

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

Override this class and implement its virtual methods to hook into the Quantum server callbacks. More...

Public Member Functions

bool CanSendInput (Int32 player, int tick)
 Prevent sending input for slots that just disconnected (previous player) More...
 
void DisconnectClient (DeterministicPluginClient client, String message)
 Disconnect a client. More...
 
ICollection< Int32 > GetActorIds ()
 Retrieve a collection 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...
 
void GetClientIds (List< string > clientIds)
 Retrieve a list of all client ids. More...
 
Boolean IsRealPlayer (Int32 index)
 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 OnDeterministicClientJoinedSession (DeterministicPluginClient client)
 Is called after the client joined the session and player slots have been assigned. This callback subsequentially follows OnDeterministicClientJoinRequestSession(DeterministicPluginClient, Join). More...
 
virtual Boolean OnDeterministicClientJoinRequestSession (DeterministicPluginClient client, Join joinData)
 Is called before a client is permitted to join the session. More...
 
virtual Boolean OnDeterministicCommand (DeterministicPluginClient client, Command cmd)
 Is called before a player command is fed to the simulation. 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, SimulationStart startData)
 Is called when the late-joining or reconnecting client is about to receive the simulation start event. More...
 
virtual Boolean OnDeterministicPlayerDataSet (DeterministicPluginClient client, SetPlayerData playerData)
 Is called before runtime player data for a client is processed. The serialized runtime player data can be changed this way: More...
 
virtual void OnDeterministicRuntimeConfig (DeterministicPluginClient client, RuntimeConfig configData)
 The RuntimeConfig is sent by the clients. First come, first serve. This method is called (once per session) before the runtime config is applied. Check of modify values here. Deserialize and serialize the modified data to RuntimeConfig.Config. 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 OnDeterministicSessionConfig (DeterministicPluginClient client, SessionConfig configData)
 Is called before a DeterministicSessionConfig that was sent by a client is applied to the simulation. Deserialize and serialize SessionConfig.Config to modify the content. More...
 
virtual Boolean OnDeterministicSnapshotRequested (ref Int32 tick, ref byte[] data)
 When client request a shapshots this method is called before the request is forwarded to other clients. This gives the opportunity, if the server runs the simulation itself, to send the snapshot directly to the client. More...
 
virtual void OnDeterministicStartSession ()
 Is called when the simulation has been started. More...
 
virtual void OnDeterministicUpdate ()
 Is called during each update tick after the input has been processed. More...
 
void SendDeterministicCommand (Command command)
 Call this method to inject a command into the simulation from the server. More...
 
void SetDeterministicPlayerData (SetPlayerData playerData)
 Call this method to continue the interupted flow of OnDeterministicPlayerDataSet(DeterministicPluginClient, SetPlayerData). The original client sender is encoded playerData.Index. More...
 
void SetDeterministicRuntimeConfig (Byte[] configData)
 Usually the RuntimeConfig object (from the simulation code project) is sent by the clients. First come, first serve. Use this method to set if from the server for modifications or more protection. Session need to be in DeterministicPluginSessionState.Idle state. More...
 
void SetDeterministicSessionConfig (DeterministicSessionConfig config)
 Usually the DeterministicSessionConfig is sent by the clients. First come, first serve. Call this method to set it from the server for more protection. Session need to be in DeterministicPluginSessionState.Idle state. More...
 
void SetGameConfigs (byte[] runtimeConfig, object sessionConfig, bool sessionConfigPlayerCountIsVariable=false)
 Sets the game configs used for the session. This method is used to set the SessionConfig from the dashboard. Will not overwrite configs that were set by other means before. OnDeterministicSessionConfig(DeterministicPluginClient, Protocol.SessionConfig) will not be called once the SessionConfig has been set by this. More...
 

Properties

Int32 ClientCount [get]
 Corresponds to the room size. More...
 
Int32 PlayerCount [get]
 Quantum player count as set in DeterministicSessionConfig.PlayerCount More...
 
IHost PluginHost [get]
 Access the plugin host object More...
 
DeterministicPluginSession Session [get]
 Access the current running session. More...
 
bool SkipFixedInputSizeValidation [get, set]
 If fixed input is used the server normally validates input send by clients and disconnects them on errors. This can disabled by setting this bool. More...
 

Detailed Description

Override this class and implement its virtual methods to hook into the Quantum server callbacks.

Member Function Documentation

◆ OnDeterministicPlayerDataSet()

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

Is called before runtime player data for a client is processed. The serialized runtime player data can be changed this way:

var runtimePlayer = RuntimePlayer.FromByteArray(playerData.Data);
runPlayer.InitialHealth = 10;
playerData.Data = RuntimePlayer.ToByteArray(runtimePlayer);

It is possible to return false to stop the processing, send an asynchronous HTTP request (USE PHOTON HTTP API) to another backend and continue the player data processing later by calling SetDeterministicPlayerData(SetPlayerData). Cache the playerData while waiting for the request answer. The sender is encoded inside the message itself, so no need to cache the client object.

Parameters
clientClient object
playerDataPlayer data message
Returns
True to continue processing the player data

◆ OnDeterministicSnapshotRequested()

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

When client request a shapshots this method is called before the request is forwarded to other clients. This gives the opportunity, if the server runs the simulation itself, to send the snapshot directly to the client.

tick = container.FrameVerified.Number
data = container.FrameVerified.Serialize(DeterministicFrameSerializeMode.Serialize)
return true;
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,
Command  cmd 
)
inlinevirtual

Is called before a player command is fed to the simulation.

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

◆ SetDeterministicPlayerData()

void Photon.Deterministic.Server.DeterministicServer.SetDeterministicPlayerData ( SetPlayerData  playerData)
inline

Call this method to continue the interupted flow of OnDeterministicPlayerDataSet(DeterministicPluginClient, SetPlayerData). The original client sender is encoded playerData.Index.

Parameters
playerDataSetPlayerData message with a serialized RuntimePlayer object

◆ SendDeterministicCommand()

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

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

Parameters
commandCommand object

◆ OnDeterministicClientJoinRequestSession()

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

Is called before a client is permitted to join the session.

Parameters
clientClient object
joinDataJoin message data
Returns
True to let the client join the game

◆ OnDeterministicClientJoinedSession()

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

Is called after the client joined the session and player slots have been assigned. This callback subsequentially follows OnDeterministicClientJoinRequestSession(DeterministicPluginClient, Join).

Parameters
clientClient object

◆ OnDeterministicSessionConfig()

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

Is called before a DeterministicSessionConfig that was sent by a client is applied to the simulation. Deserialize and serialize SessionConfig.Config to modify the content.

Parameters
clientClient object
configDataProtocol message with encoded DeterministicSessionConfig

◆ OnDeterministicRuntimeConfig()

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

The RuntimeConfig is sent by the clients. First come, first serve. This method is called (once per session) before the runtime config is applied. Check of modify values here. Deserialize and serialize the modified data to RuntimeConfig.Config.

Parameters
clientClient object
configDataSerialized runtime config

◆ OnDeterministicLateStart()

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

Is called when the 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

◆ SetDeterministicSessionConfig()

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

Usually the DeterministicSessionConfig is sent by the clients. First come, first serve. Call this method to set it from the server for more protection. Session need to be in DeterministicPluginSessionState.Idle state.

Parameters
configDeterministic config

◆ SetDeterministicRuntimeConfig()

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

Usually the RuntimeConfig object (from the simulation code project) is sent by the clients. First come, first serve. Use this method to set if from the server for modifications or more protection. Session need to be in DeterministicPluginSessionState.Idle state.

Parameters
configData

◆ 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

◆ OnDeterministicStartSession()

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

Is called when the simulation has been started.

◆ 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

◆ OnDeterministicUpdate()

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

Is called during each update tick after the input has been processed.

◆ 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()

ICollection<Int32> Photon.Deterministic.Server.DeterministicServer.GetActorIds ( )
inline

Retrieve a collection 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  index)
inline

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

Parameters
indexPlayer index
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

◆ SetGameConfigs()

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

Sets the game configs used for the session. This method is used to set the SessionConfig from the dashboard. Will not overwrite configs that were set by other means before. OnDeterministicSessionConfig(DeterministicPluginClient, Protocol.SessionConfig) will not be called once the SessionConfig has been set by this.

Parameters
runtimeConfigBinary RuntimePlayer
sessionConfigSessionConfig as object (original type has to be DeterministicSessionConfig)
sessionConfigPlayerCountIsVariablePlayerCount from SessionConfig is considered to me the min possible and clients can set higher values.

Property Documentation

◆ ClientCount

Int32 Photon.Deterministic.Server.DeterministicServer.ClientCount
get

Corresponds to the room size.

◆ PlayerCount

Int32 Photon.Deterministic.Server.DeterministicServer.PlayerCount
get

Quantum player count as set in DeterministicSessionConfig.PlayerCount

◆ Session

DeterministicPluginSession Photon.Deterministic.Server.DeterministicServer.Session
get

Access the current running session.

◆ SkipFixedInputSizeValidation

bool Photon.Deterministic.Server.DeterministicServer.SkipFixedInputSizeValidation
getset

If fixed input is used the server normally validates input send by clients and disconnects them on errors. This can disabled by setting this bool.

◆ PluginHost

IHost Photon.Deterministic.Server.DeterministicServer.PluginHost
get

Access the plugin host object