Photon Server API
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
Photon.LoadBalancing.GameServer.Game Class Reference
Inheritance diagram for Photon.LoadBalancing.GameServer.Game:
Photon.Hive.HiveHostGame Photon.Hive.HiveGame Photon.SocketServer.Net.IHttpRequestQueueCounters Photon.SocketServer.IUnknownTypeMapper Photon.Hive.Room Photon.LoadBalancing.UnitTests.UnifiedServer.OfflineExtra.TestGame

Public Member Functions

 Game (GameApplication application, string gameId, Hive.Caching.RoomCacheBase roomCache=null, IPluginManager pluginManager=null, string pluginName="", Dictionary< string, object > environment=null, ExtendedPoolFiber executionFiber=null)
 Initializes a new instance of the Game class. More...
 
override void OnClose ()
 
- Public Member Functions inherited from Photon.Hive.HiveHostGame
 HiveHostGame (string gameName, RoomCacheBase roomCache, IGameStateFactory gameStateFactory=null, int maxEmptyRoomTTL=0, IPluginManager pluginManager=null, string pluginName="", Dictionary< string, object > environment=null, int lastTouchLimitMilliseconds=0, int lastTouchCheckIntervalMilliseconds=0, HttpRequestQueueOptions httpRequestQueueOptions=null, ExtendedPoolFiber executionFiber=null)
 
override bool BeforeRemoveFromCache ()
 Called by the RoomCacheBase if the room is about to be removed from the cache. More...
 
override void OnClose ()
 
Dictionary< byte, byte[]> GetGameStateAsByteArray ()
 
bool SetGameState (Dictionary< byte, byte[]> state)
 
void HttpQueueRequestsIncrement ()
 
void HttpQueueResponsesIncrement ()
 
void HttpQueueSuccessIncrement ()
 
void HttpQueueTimeoutIncrement ()
 
void HttpQueueErrorsIncrement ()
 
void HttpQueueOfflineResponsesIncrement ()
 
void HttpQueueConcurrentRequestsIncrement ()
 
void HttpQueueConcurrentRequestsDecrement ()
 
void HttpQueueQueuedRequestsIncrement ()
 
void HttpQueueQueuedRequestsDecrement ()
 
void HttpRequestExecuteTimeIncrement (long ticks)
 
void HttpQueueOnlineQueueCounterIncrement ()
 
void HttpQueueOnlineQueueCounterDecrement ()
 
void HttpQueueBackedoffRequestsIncrement ()
 
void HttpQueueBackedoffRequestsDecrement ()
 
void HttpRequestIncrement ()
 
void HttpSuccessIncrement ()
 
void HttpTimeoutIncrement ()
 
void HttpErrorsIncrement ()
 
void HttpResponseIncrement ()
 
bool OnUnknownType (Type type, ref object obj)
 
override void RemoveInactiveActor (Actor actor)
 
SerializableGameState GetSerializableGameState ()
 
Dictionary< string, object > GetGameState ()
 
bool SetGameState (Dictionary< string, object > state)
 
- Public Member Functions inherited from Photon.Hive.HiveGame
 HiveGame (string gameName, RoomCacheBase roomCache, IGameStateFactory gameStateFactory=null, int maxEmptyRoomTTL=0, int lastTouchLimitMilliseconds=0, int lastTouchCheckIntervalMilliseconds=0, ExtendedPoolFiber executionFiber=null)
 Initializes a new instance of the HiveGame class. More...
 
override string ToString ()
 
bool CheckBeforeJoinThisIsNewCreatedRoom (JoinGameRequest request)
 
bool CheckAfterJoinThisIsNewCreatedRoom (bool isNewActor)
 
void PublishEventDiconnected (Actor actor, int?newMasterClientId)
 
void OnActorRemoved (Actor actor)
 
void OnActorDeactivated (Actor actor)
 
- Public Member Functions inherited from Photon.Hive.Room
 Room (string name, RoomCacheBase roomCache=null, IGameStateFactory gameStateFactory=null, int maxEmptyRoomTTL=0, ExtendedPoolFiber executionFiber=null)
 Initializes a new instance of the Room class without a room name. More...
 
override string ToString ()
 
void EnqueueMessage (IMessage message)
 Enqueues an IMessage to the end of the execution queue. More...
 
void EnqueueOperation (HivePeer peer, OperationRequest operationRequest, SendParameters sendParameters)
 Enqueues an OperationRequest to the end of the execution queue. More...
 
IDisposable ScheduleMessage (IMessage message, long timeMs)
 Schedules a message to be processed after a specified time. More...
 
void Dispose ()
 Releases resources used by this instance. More...
 
void Release ()
 

Public Attributes

readonly GameApplication Application
 

Protected Member Functions

override void Dispose (bool disposing)
 Releases unmanaged and - optionally - managed resources More...
 
override void JoinFailureHandler (byte leaveReason, HivePeer peer, JoinGameRequest request)
 
override bool ProcessJoin (int actorNr, JoinGameRequest joinRequest, SendParameters sendParameters, ProcessJoinParams prms, HivePeer peer)
 
override bool ProcessCreateGame (HivePeer peer, JoinGameRequest joinRequest, SendParameters sendParameters)
 
override void OnGamePropertiesChanged (SetPropertiesRequest request)
 
override void DeactivateActor (Actor actor)
 
override void CleanupActor (Actor actor)
 
override void ExecuteOperation (HivePeer peer, OperationRequest operationRequest, SendParameters sendParameters)
 This method is invoked sequentially for each operation request enqueued in the ExecutionFiber using the EnqueueOperation method. More...
 
override void ProcessMessage (Photon.Hive.Messages.IMessage message)
 
virtual void CheckGame ()
 Check routine to validate that the game is valid (ie., it is removed from the game cache if it has no longer any actors etc.). CheckGame() is called by the Application at regular intervals. More...
 
virtual void NotifyMasterUserDeactivated (string userId)
 
virtual void NotifyMasterUserLeft (string userId)
 
virtual void NotifyMasterUserFailedToAdd (GameClientPeer peer)
 
virtual void NotifyMasterUserAdded (string userId, string[] slots)
 
virtual void NotifyMasterUserAdded (string[] userIds, string[] slots)
 
override void OnActorBanned (Actor actor)
 
UpdateGameEvent GetUpdateGameEvent ()
 
virtual void UpdateGameStateOnMasterOnCreate (JoinGameRequest joinRequest, HivePeer peer)
 
virtual void UpdateGameStateOnMaster (byte?newMaxPlayer=null, bool?newIsOpen=null, bool?newIsVisble=null, object[] lobbyPropertyFilter=null, Hashtable gameProperties=null, string[] newUserId=null, string removedUserId=null, bool reinitialize=false, string[] inactiveList=null, ExcludedActorInfo[] excludedActorInfos=null, string[] expectedList=null, bool?checkUserIdOnJoin=null)
 
virtual void UpdateGameStateOnMaster (UpdateGameEvent updateEvent)
 
virtual void RemoveGameStateFromMaster ()
 
- Protected Member Functions inherited from Photon.Hive.HiveHostGame
override void HandleCreateGameOperation (HivePeer peer, SendParameters sendParameters, CreateGameRequest createGameRequest)
 
override void HandleJoinGameOperation (HivePeer peer, SendParameters sendParameters, JoinGameRequest joinGameRequest)
 Handles the JoinGameRequest: Joins a peer to a room and calls PublishJoinEvent. Before a JoinOperation reaches this point (inside a room), the HivePeer made sure that it is removed from the previous Room (if there was any). More...
 
bool ReinitGame ()
 
override void HandleLeaveOperation (HivePeer peer, SendParameters sendParameters, LeaveRequest leaveOperation)
 Handles the LeaveRequest and calls HiveGame.RemovePeerFromGame. More...
 
override void HandleRaiseEventOperation (HivePeer peer, RaiseEventRequest raiseEventRequest, SendParameters sendParameters)
 Handles the RaiseEventRequest: Sends a CustomEvent to actors in the room. More...
 
override void HandleRemovePeerMessage (HivePeer peer, int reason, string details)
 
override void HandleSetPropertiesOperation (HivePeer peer, SetPropertiesRequest request, SendParameters sendParameters)
 Handles the SetPropertiesRequest and sends event PropertiesChangedEvent to all Actors in the room. More...
 
virtual bool ProcessBeforeJoinGame (JoinGameRequest joinRequest, SendParameters sendParameters, HivePeer peer)
 
virtual bool ProcessBeforeSetProperties (HivePeer peer, SetPropertiesRequest request, Hashtable oldValues, SendParameters sendParameters)
 
virtual bool ProcessSetProperties (HivePeer peer, bool result, string errorMsg, SetPropertiesRequest request, SendParameters sendParameters)
 
virtual bool ProcessBeforeCloseGame (CloseRequest request)
 
override void JoinFailureHandler (byte leaveReason, HivePeer peer, JoinGameRequest request)
 
virtual bool ProcessCloseGame (object state)
 
virtual bool ProcessLeaveGame (int actorNr, LeaveRequest request, SendParameters sendParameters, HivePeer peer)
 
virtual bool ProcessRaiseEvent (HivePeer peer, RaiseEventRequest raiseEventRequest, SendParameters sendParameters, Actor actor)
 
override OperationResponse GetUserJoinResponse (JoinGameRequest joinRequest, int actorNr, ProcessJoinParams prms)
 
- Protected Member Functions inherited from Photon.Hive.HiveGame
bool CreateGame (HivePeer peer, JoinGameRequest request, SendParameters sendParameters)
 
override void ExecuteOperation (HivePeer peer, OperationRequest operationRequest, SendParameters sendParameters)
 Called for each operation in the execution queue. Every Room has a queue of incoming operations to execute. Per game ExecuteOperation is never executed multi-threaded, thus all code executed here has thread safe access to all instance members. More...
 
Actor GetActorByPeer (HivePeer peer)
 Gets the actor for a HivePeer. More...
 
Hashtable GetLobbyGameProperties (Hashtable source)
 
Hashtable GetLobbyGameProperties (Hashtable source, HashSet< object > list)
 
virtual void HandleChangeGroupsOperation (HivePeer peer, ChangeGroups changeGroupsRequest, SendParameters sendParameters)
 
bool UpdateCacheSlice (HivePeer peer, byte op, int?sliceIndex, ref string message)
 
virtual void HandleDebugGameOperation (HivePeer peer, DebugGameRequest request, SendParameters sendParameters)
 
virtual void HandleGetPropertiesOperation (HivePeer peer, GetPropertiesRequest getPropertiesRequest, SendParameters sendParameters)
 Handles the GetPropertiesRequest operation: Sends the properties with the OperationResponse. More...
 
bool Join (HivePeer peer, JoinGameRequest joinRequest, SendParameters sendParameters)
 
bool JoinApplyGameStateChanges (HivePeer peer, JoinGameRequest joinRequest, SendParameters sendParameters, out Actor actor)
 
virtual void SendErrorResponse (HivePeer peer, byte opCode, ErrorCode errorCode, string msg, SendParameters sendParameters, Dictionary< byte, object > errorData=null)
 
virtual bool AddExpectedUsers (JoinGameRequest joinRequest)
 
bool JoinSendResponseAndEvents (HivePeer peer, JoinGameRequest joinRequest, SendParameters sendParameters, int actorNr, ProcessJoinParams prms)
 
void LeaveOperationHandler (HivePeer peer, SendParameters sendParameters, LeaveRequest request)
 
void LogOperation (HivePeer peer, OperationRequest operationRequest)
 
override void ProcessMessage (IMessage message)
 Processes a game message. Messages are used for internal communication. Per default only message RemovePeerFromGame is handled, a message that is sent when a player leaves a game due to disconnect or due to a subsequent join to a different game. More...
 
void PublishEventCache (HivePeer litePeer, JoinGameRequest joinRequest)
 Sends all cached events to a peer. More...
 
virtual void PublishJoinEvent (HivePeer peer, JoinGameRequest joinRequest)
 Sends a JoinEvent to all Actors. More...
 
virtual void PublishLeaveEvent (Actor actor, int?newMasterClientId)
 Sends a LeaveEvent to all Actors. More...
 
bool RaiseEventOperationHandler (HivePeer peer, RaiseEventRequest raiseEventRequest, SendParameters sendParameters, Actor actor)
 
virtual int RemovePeerFromGame (HivePeer peer, bool isCommingBack)
 Removes a peer from the game. This method is called if a client sends a LeaveRequest or disconnects. More...
 
bool SetPropertiesRequestHandler (HivePeer peer, SetPropertiesRequest request, SendParameters sendParameters)
 
void RevertProperties (IDictionary oldPropertyValues, SetPropertiesRequest request)
 
Hashtable GetOldPropertyValues (SetPropertiesRequest request)
 
bool ValidateAndFillSetPropertiesRequest (HivePeer peer, SetPropertiesRequest request, out string errorMsg)
 
void PublishResultsAndSetGameProperties (bool propertiesUpdateResult, string errorMessage, SetPropertiesRequest request, HivePeer peer, SendParameters sendParameters)
 
virtual bool SetNewPropertyValues (SetPropertiesRequest request, out string errorMessage)
 
virtual bool TryAddPeerToGame (HivePeer peer, int actorNr, out Actor actor, out bool isNewActor, out ErrorCode errorcode, out string reason, JoinGameRequest joinRequest)
 Tries to add a HivePeer to this game instance. More...
 
bool UpdateEventCache (Actor actor, RaiseEventRequest raiseEventRequest, out string msg)
 Helper method of HandleRaiseEventOperation. Stores an event for new actors. More...
 
bool UpdateEventCache (Actor actor, byte eventCode, object data, byte cacheOp, out string msg)
 
bool UpdateEventCache (Actor actor, byte evCode, object data, CacheOperation cacheOp, ref string msg)
 
bool ValidateGame (HivePeer peer, JoinGameRequest joinGameRequest, SendParameters sendParameters)
 
- Protected Member Functions inherited from Photon.Hive.Room
 Room (string name, ExtendedPoolFiber executionFiber, RoomCacheBase roomCache, IGameStateFactory gameStateFactory=null, int maxEmptyRoomTTL=0)
 Initializes a new instance of the Room class. More...
 
void PublishEvent (HiveEventBase e, Actor actor, SendParameters sendParameters)
 Publishes an event to a single actor on a specified channel. More...
 
void PublishEvent (HiveEventBase e, IEnumerable< Actor > actorList, SendParameters sendParameters)
 Publishes an event to a list of actors on a specified channel. More...
 
void PublishEvent (EventData e, IEnumerable< Actor > actorList, SendParameters sendParameters)
 Publishes an event to a list of actors on a specified channel. More...
 
void ScheduleRoomRemoval (int roomLiveTime)
 Schedules the removal of the room instance from the cache. The room will be removed after the specified time if there are no room references left. More...
 
void TryRemoveRoomFromCache ()
 Removes the room instance from the cache if there are no references to the instance left. More...
 

Additional Inherited Members

- Protected Types inherited from Photon.Hive.Room
enum  RemoveState {
  RemoveState.Alive, RemoveState.TryRemoveRoomFromCacheCalled, RemoveState.RoomRemoved, RemoveState.TryRemoveRoomFromCacheCalledRoomNotRemoved,
  RemoveState.ProcessCloseGameCalled, RemoveState.TriggerPluginOnCloseCalled, RemoveState.AliveGotNewPlayer, RemoveState.ScheduleTriggerPluginOnCloseCalled,
  RemoveState.ProcessBeforeCloseGameCalled, RemoveState.ProcessBeforeCloseGameCalledEmptyRoomLiveTimeLECalled, RemoveState.BeforeRemoveFromCacheCalled, RemoveState.BeforeRemoveFromCacheActionCalled,
  RemoveState.GameDisposeCalled
}
 
- Static Protected Member Functions inherited from Photon.Hive.HiveHostGame
static string GetCallStack ()
 
- Protected Attributes inherited from Photon.Hive.HiveHostGame
CallCounter PendingPluginContinue = new CallCounter()
 
CallEnv callEnv
 
- Protected Attributes inherited from Photon.Hive.HiveGame
readonly LogQueue LogQueue
 
readonly int LastTouchLimitMilliseconds
 
readonly int LastTouchCheckIntervalMilliseconds
 
IHiveGameAppCounters gameAppCounters = NullHiveGameAppCounters.Instance
 
- Protected Attributes inherited from Photon.Hive.Room
readonly RoomCacheBase roomCache
 
readonly IGameStateFactory gameStateFactory
 
string RemoveRoomPathString
 
GameState roomState
 
- Static Protected Attributes inherited from Photon.Hive.HiveHostGame
static readonly IHttpQueueCountersInstance _Total = HttpQueuePerformanceCounters.GetInstance("_Total")
 
static readonly IHttpQueueCountersInstance CountersInstance
 
- Properties inherited from Photon.Hive.HiveHostGame
IGamePlugin Plugin [get]
 
IPluginInstance PluginInstance [get]
 
Dictionary< string, object > Environment [get, set]
 
int HttpForwardedOperationsLimit [get, protected set]
 
override bool IsPersistent [get]
 
object this[object key] [get, set]
 
- Properties inherited from Photon.Hive.HiveGame
IHiveGameAppCounters GameAppCounters [get, set]
 
int MasterClientId [get]
 
virtual bool IsPersistent [get]
 
IEnumerable< ActorInactiveActors [get]
 
IEnumerable< ActorActors [get]
 
bool PublishUserId [get, set]
 
bool IsOpen [get, set]
 
bool IsVisible [get, set]
 
string LobbyId [get, set]
 
bool DeleteCacheOnLeave [get, set]
 Gets or sets a value indicating whether cached events are automaticly deleted for actors which are leaving a room. More...
 
HashSet< object > LobbyProperties [get, set]
 Contains the keys of the game properties hashtable which should be listet in the lobby. More...
 
AppLobbyType LobbyType [get, set]
 
byte MaxPlayers [get, set]
 
int PlayerTTL [get, set]
 Player live time More...
 
bool SuppressRoomEvents [get, set]
 Gets or sets a value indicating if common room events (Join, Leave) will suppressed. More...
 
RoomEventCacheManager EventCache [get]
 
EventCacheDictionary ActorEventCache [get]
 Contains Caching.EventCaches for all actors. More...
 
GroupManager GroupManager [get]
 
ActorsManager ActorsManager [get]
 
GameState RoomState [get]
 
bool CheckUserOnJoin [get, set]
 
- Properties inherited from Photon.Hive.Room
RemoveState RemoveRoomPath [get, set]
 
ExtendedPoolFiber ExecutionFiber [get]
 Gets a PoolFiber instance used to synchronize access to this instance. More...
 
bool IsDisposed [get]
 Gets a value indicating whether IsDisposed. More...
 
string Name [get]
 Gets the name (id) of the room. More...
 
int EmptyRoomLiveTime [get, protected set]
 Gets or sets a value indicating how long the room instance will be keeped alive in the room cache after all peers have left the room. More...
 
int MaxEmptyRoomTTL [get]
 
IDisposable RemoveTimer [get, set]
 Timer for removing room More...
 
PropertyBag< object > Properties [get]
 Gets a PropertyBag instance used to store custom room properties. More...
 

Constructor & Destructor Documentation

Photon.LoadBalancing.GameServer.Game.Game ( GameApplication  application,
string  gameId,
Hive.Caching.RoomCacheBase  roomCache = null,
IPluginManager  pluginManager = null,
string  pluginName = "",
Dictionary< string, object >  environment = null,
ExtendedPoolFiber  executionFiber = null 
)
inline

Initializes a new instance of the Game class.

Parameters
applicationThe photon application instance the game belongs to.
gameIdThe game id.
roomCacheThe room cache the game belongs to.
pluginManagerplugin creator
pluginNamePlugin name which client expects to be loaded
environmentdifferent environment parameters
executionFiberFiber which will execute all rooms actions

Member Function Documentation

virtual void Photon.LoadBalancing.GameServer.Game.CheckGame ( )
inlineprotectedvirtual

Check routine to validate that the game is valid (ie., it is removed from the game cache if it has no longer any actors etc.). CheckGame() is called by the Application at regular intervals.

override void Photon.LoadBalancing.GameServer.Game.CleanupActor ( Actor  actor)
inlineprotectedvirtual

Reimplemented from Photon.Hive.HiveGame.

override void Photon.LoadBalancing.GameServer.Game.DeactivateActor ( Actor  actor)
inlineprotectedvirtual

Reimplemented from Photon.Hive.HiveGame.

override void Photon.LoadBalancing.GameServer.Game.Dispose ( bool  disposing)
inlineprotectedvirtual

Releases unmanaged and - optionally - managed resources

Parameters
disposingtrue to release both managed and unmanaged resources; false to release only unmanaged resources.

Reimplemented from Photon.Hive.Room.

override void Photon.LoadBalancing.GameServer.Game.ExecuteOperation ( HivePeer  peer,
OperationRequest  operation,
SendParameters  sendParameters 
)
inlineprotectedvirtual

This method is invoked sequentially for each operation request enqueued in the ExecutionFiber using the EnqueueOperation method.

Parameters
peerThe peer.
operationThe operation request.
sendParametersThe send Parameters.

Reimplemented from Photon.Hive.Room.

UpdateGameEvent Photon.LoadBalancing.GameServer.Game.GetUpdateGameEvent ( )
inlineprotected
override void Photon.LoadBalancing.GameServer.Game.JoinFailureHandler ( byte  leaveReason,
HivePeer  peer,
JoinGameRequest  request 
)
inlineprotectedvirtual

Reimplemented from Photon.Hive.HiveGame.

virtual void Photon.LoadBalancing.GameServer.Game.NotifyMasterUserAdded ( string  userId,
string[]  slots 
)
inlineprotectedvirtual
virtual void Photon.LoadBalancing.GameServer.Game.NotifyMasterUserAdded ( string[]  userIds,
string[]  slots 
)
inlineprotectedvirtual
virtual void Photon.LoadBalancing.GameServer.Game.NotifyMasterUserDeactivated ( string  userId)
inlineprotectedvirtual
virtual void Photon.LoadBalancing.GameServer.Game.NotifyMasterUserFailedToAdd ( GameClientPeer  peer)
inlineprotectedvirtual
virtual void Photon.LoadBalancing.GameServer.Game.NotifyMasterUserLeft ( string  userId)
inlineprotectedvirtual
override void Photon.LoadBalancing.GameServer.Game.OnActorBanned ( Actor  actor)
inlineprotectedvirtual

Reimplemented from Photon.Hive.HiveHostGame.

override void Photon.LoadBalancing.GameServer.Game.OnClose ( )
inlinevirtual

Reimplemented from Photon.Hive.Room.

override void Photon.LoadBalancing.GameServer.Game.OnGamePropertiesChanged ( SetPropertiesRequest  request)
inlineprotectedvirtual

Reimplemented from Photon.Hive.HiveGame.

override bool Photon.LoadBalancing.GameServer.Game.ProcessCreateGame ( HivePeer  peer,
JoinGameRequest  joinRequest,
SendParameters  sendParameters 
)
inlineprotectedvirtual

Reimplemented from Photon.Hive.HiveHostGame.

override bool Photon.LoadBalancing.GameServer.Game.ProcessJoin ( int  actorNr,
JoinGameRequest  joinRequest,
SendParameters  sendParameters,
ProcessJoinParams  prms,
HivePeer  peer 
)
inlineprotectedvirtual

Reimplemented from Photon.Hive.HiveHostGame.

override void Photon.LoadBalancing.GameServer.Game.ProcessMessage ( Photon.Hive.Messages.IMessage  message)
inlineprotected
virtual void Photon.LoadBalancing.GameServer.Game.RemoveGameStateFromMaster ( )
inlineprotectedvirtual
virtual void Photon.LoadBalancing.GameServer.Game.UpdateGameStateOnMaster ( byte?  newMaxPlayer = null,
bool?  newIsOpen = null,
bool?  newIsVisble = null,
object[]  lobbyPropertyFilter = null,
Hashtable  gameProperties = null,
string[]  newUserId = null,
string  removedUserId = null,
bool  reinitialize = false,
string[]  inactiveList = null,
ExcludedActorInfo[]  excludedActorInfos = null,
string[]  expectedList = null,
bool?  checkUserIdOnJoin = null 
)
inlineprotectedvirtual
virtual void Photon.LoadBalancing.GameServer.Game.UpdateGameStateOnMaster ( UpdateGameEvent  updateEvent)
inlineprotectedvirtual
virtual void Photon.LoadBalancing.GameServer.Game.UpdateGameStateOnMasterOnCreate ( JoinGameRequest  joinRequest,
HivePeer  peer 
)
inlineprotectedvirtual

Member Data Documentation

readonly GameApplication Photon.LoadBalancing.GameServer.Game.Application