A room has Actors, can have properties, and provides an ExecutionFiber with a few wrapper methods to solve otherwise complicated threading issues: All actions enqueued to the ExecutionFiber are executed in a serial order. Operations of all Actors in a room are handled via ExecutionFiber.
More...
|
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
} |
|
|
| Room (string name, ExtendedPoolFiber executionFiber, RoomCacheBase roomCache, IGameStateFactory gameStateFactory=null, int maxEmptyRoomTTL=0) |
| Initializes a new instance of the Room class. More...
|
|
virtual void | Dispose (bool dispose) |
| Releases unmanaged and - optionally - managed resources More...
|
|
virtual void | ExecuteOperation (HivePeer peer, Operation operation, SendParameters sendParameters) |
| This method is invoked sequentially for each operation request enqueued in the ExecutionFiber using the EnqueueOperation method. More...
|
|
virtual void | ProcessMessage (IMessage message) |
| This method is invoked sequentially for each message enqueued by the EnqueueMessage or ScheduleMessage method. 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 | PublishErrorInfoEvent (string errorMsg, IEnumerable< Actor > actorList, SendParameters sendParameters) |
|
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...
|
|
virtual void | OnClose () |
|
A room has Actors, can have properties, and provides an ExecutionFiber with a few wrapper methods to solve otherwise complicated threading issues: All actions enqueued to the ExecutionFiber are executed in a serial order. Operations of all Actors in a room are handled via ExecutionFiber.
◆ RemoveState
Enumerator |
---|
Alive | |
TryRemoveRoomFromCacheCalled | |
RoomRemoved | |
TryRemoveRoomFromCacheCalledRoomNotRemoved | |
ProcessCloseGameCalled | |
TriggerPluginOnCloseCalled | |
AliveGotNewPlayer | |
ScheduleTriggerPluginOnCloseCalled | |
ProcessBeforeCloseGameCalled | |
ProcessBeforeCloseGameCalledEmptyRoomLiveTimeLECalled | |
BeforeRemoveFromCacheCalled | |
BeforeRemoveFromCacheActionCalled | |
GameDisposeCalled | |
◆ Room() [1/2]
Initializes a new instance of the Room class without a room name.
- Parameters
-
name | The room name. |
roomCache | The RoomCacheBase instance to which the room belongs. |
gameStateFactory | Fatory for game state |
maxEmptyRoomTTL | A value indicating how long the room instance will be keeped alive in the room cache after all peers have left the room. |
executionFiber | Fiber which will execute rooms actions |
◆ Room() [2/2]
Initializes a new instance of the Room class.
- Parameters
-
name | The room name. |
executionFiber | The execution fiber used to synchronize access to this instance. |
roomCache | The RoomCacheBase instance to which the room belongs. |
gameStateFactory | Fatory for game state |
maxEmptyRoomTTL | A value indicating how long the room instance will be keeped alive in the room cache after all peers have left the room. |
◆ BeforeRemoveFromCache()
virtual bool Photon.Hive.Room.BeforeRemoveFromCache |
( |
| ) |
|
|
inlinevirtual |
Called by the RoomCacheBase if the room is about to be removed from the cache.
- Returns
- True if the room should be automaticly by removed by the RoomCacheBase. False if the room has an custom remove implementation and will remove itself from the cache.
The default implementation checks if the EmptyRoomLiveTime value is set to a value greater zero. If it's set the method will return false to indicate that the cache should not remove this instance automaticly. The removal of the room is then scheduled using the ExecutionFiber.
Reimplemented in Photon.Hive.HiveHostGame.
◆ Dispose() [1/2]
void Photon.Hive.Room.Dispose |
( |
| ) |
|
|
inline |
Releases resources used by this instance.
◆ Dispose() [2/2]
virtual void Photon.Hive.Room.Dispose |
( |
bool |
dispose | ) |
|
|
inlineprotectedvirtual |
◆ EnqueueMessage()
void Photon.Hive.Room.EnqueueMessage |
( |
IMessage |
message | ) |
|
|
inline |
Enqueues an IMessage to the end of the execution queue.
- Parameters
-
message | The message to enqueue. |
ProcessMessage is called sequentially for each operation request stored in the execution queue. Using an execution queue ensures that messages are processed in order and sequentially to prevent object synchronization (multi threading).
◆ EnqueueOperation()
Enqueues an OperationRequest to the end of the execution queue.
- Parameters
-
peer | The peer. |
operationRequest | The operation request to enqueue. |
sendParameters | The send Parameters. |
ExecuteOperation is called sequentially for each operation request stored in the execution queue. Using an execution queue ensures that operation request are processed in order and sequentially to prevent object synchronization (multi threading).
◆ ExecuteOperation()
This method is invoked sequentially for each operation request enqueued in the ExecutionFiber using the EnqueueOperation method.
- Parameters
-
peer | The peer. |
operation | The operation request. |
sendParameters | The send Parameters. |
Reimplemented in Photon.Hive.HiveGame.
◆ OnClose()
virtual void Photon.Hive.Room.OnClose |
( |
| ) |
|
|
inlineprotectedvirtual |
◆ ProcessMessage()
virtual void Photon.Hive.Room.ProcessMessage |
( |
IMessage |
message | ) |
|
|
inlineprotectedvirtual |
◆ PublishErrorInfoEvent()
void Photon.Hive.Room.PublishErrorInfoEvent |
( |
string |
errorMsg, |
|
|
IEnumerable< Actor > |
actorList, |
|
|
SendParameters |
sendParameters |
|
) |
| |
|
inlineprotected |
◆ PublishEvent() [1/3]
Publishes an event to a list of actors on a specified channel.
- Parameters
-
e | The event to publish. |
actorList | A list of Actor who should receive the event. |
sendParameters | The send Parameters. |
◆ PublishEvent() [2/3]
Publishes an event to a single actor on a specified channel.
- Parameters
-
e | The event to publish. |
actor | The Actor who should receive the event. |
sendParameters | The send Parameters. |
◆ PublishEvent() [3/3]
Publishes an event to a list of actors on a specified channel.
- Parameters
-
e | The event to publish. |
actorList | A list of Actor who should receive the event. |
sendParameters | The send Parameters. |
◆ Release()
void Photon.Hive.Room.Release |
( |
| ) |
|
|
inline |
◆ ScheduleMessage()
IDisposable Photon.Hive.Room.ScheduleMessage |
( |
IMessage |
message, |
|
|
int |
timeMs |
|
) |
| |
|
inline |
Schedules a message to be processed after a specified time.
- Parameters
-
message | The message to schedule. |
timeMs | The time in milliseconds to wait before the message will be processed. |
- Returns
- an IDisposable
◆ ScheduleRoomRemoval()
void Photon.Hive.Room.ScheduleRoomRemoval |
( |
int |
roomLiveTime | ) |
|
|
inlineprotected |
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.
- Parameters
-
roomLiveTime | The time to remove the room in milliseconds. |
◆ ToString()
override string Photon.Hive.Room.ToString |
( |
| ) |
|
|
inline |
◆ TryRemoveRoomFromCache()
void Photon.Hive.Room.TryRemoveRoomFromCache |
( |
| ) |
|
|
inlineprotected |
Removes the room instance from the cache if there are no references to the instance left.
when we are here it may happens (for instacne because plugin OnCloseGame handler does some sync http request) that new players already acuired new refernces to room. and room can not be removed from cache
we had a bug in WebHooks12 and it caused Continue to be called right after sync http call. that led to big delay for this method execution. because of that confusion CheckGame method logged that empty room still in cache so, now to prevent such situation we set here MaxValue instead of min, so that CheckGame is quiet
◆ gameStateFactory
◆ removalStartTimestamp
DateTime Photon.Hive.Room.removalStartTimestamp = DateTime.MinValue |
|
protected |
◆ RemoveRoomPathString
string Photon.Hive.Room.RemoveRoomPathString |
|
protected |
◆ roomCache
◆ roomState
◆ EmptyRoomLiveTime
int Photon.Hive.Room.EmptyRoomLiveTime |
|
getprotected 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.
◆ ExecutionFiber
Gets a PoolFiber instance used to synchronize access to this instance.
A PoolFiber instance.
◆ IsDisposed
bool Photon.Hive.Room.IsDisposed |
|
get |
Gets a value indicating whether IsDisposed.
◆ MaxEmptyRoomTTL
int Photon.Hive.Room.MaxEmptyRoomTTL |
|
get |
◆ Name
string Photon.Hive.Room.Name |
|
get |
Gets the name (id) of the room.
◆ Properties
Gets a PropertyBag instance used to store custom room properties.
◆ RemoveRoomPath
◆ RemoveTimer
IDisposable Photon.Hive.Room.RemoveTimer |
|
getsetprotected |
◆ RoomCreationTS
long Photon.Hive.Room.RoomCreationTS |
|
get |
◆ UtcCreated
DateTime Photon.Hive.Room.UtcCreated |
|
get |