Base class for room caches. More...
Classes | |
class | RoomInstance |
Used to track references for a room instance. More... | |
Public Member Functions | |
bool | TryGetRoomWithoutReference (string roomId, out Room room) |
Tries to get room reference for a room with the specified id, without holding a reference to that room. More... | |
RoomReference | GetRoomReference (string roomName, PeerBase ownerPeer, params object[] args) |
Gets a room reference for a room with a specified id. If the room with the specified id does not exists, a new room will be created. More... | |
List< string > | GetRoomNames () |
Returns the names of all rooms that are currently cached in this RoomCacheBase. More... | |
virtual string | GetDebugString (string roomName) |
Gathers debug information about the specified room (actors, peers, references etc.). More... | |
bool | TryCreateRoom (string roomName, PeerBase ownerPeer, out RoomReference roomReference, params object[] args) |
Tries to create a new room. More... | |
bool | TryGetRoomReference (string roomId, PeerBase ownerPeer, out RoomReference roomReference) |
Tries to get room reference for a room with the specified id. More... | |
void | ReleaseRoomReference (RoomReference roomReference) |
Releases a room reference. The related room instance will be removed from the cache if no more references to the room exists. More... | |
bool | TryRemoveRoomInstance (Room room) |
Tries to remove a romm instance from the room cache. The room will only be removed if there are no references to the romm instance left. More... | |
Protected Member Functions | |
abstract Room | CreateRoom (string roomId, params object[] args) |
Must be implementated by inheritors to create new room instances. This method is called when a room reference is requesteted for a room that does not exists in the cache. More... | |
virtual void | OnRoomRemoved (Room room) |
Invoked if the last reference for a room is released and the room was removed from the cache. Can be overloaded by inheritors to provide a custom cleanup logic after a room has been disposed. More... | |
Protected Attributes | |
readonly Dictionary< string, RoomInstance > | RoomInstances = new Dictionary<string, RoomInstance>() |
A Dictionary used to store room instances. More... | |
readonly object | SyncRoot = new object() |
used to syncronize acces to the cache. More... | |
Base class for room caches.
|
protectedpure virtual |
Must be implementated by inheritors to create new room instances. This method is called when a room reference is requesteted for a room that does not exists in the cache.
roomId | The room id. |
args | Optionally arguments used for room creation. |
Implemented in Photon.Hive.Caching.HiveGameCache, Photon.Hive.Tests.TestGameCache, Photon.LoadBalancing.GameServer.GameCache, and Photon.LoadBalancing.UnitTests.UnifiedServer.OfflineExtra.TestGameCache.
|
inlinevirtual |
Gathers debug information about the specified room (actors, peers, references etc.).
roomName | The room name. |
|
inline |
Returns the names of all rooms that are currently cached in this RoomCacheBase.
|
inline |
Gets a room reference for a room with a specified id. If the room with the specified id does not exists, a new room will be created.
roomName | The room id. |
ownerPeer | The peer that holds this reference. |
args | Optionally arguments used for room creation. |
|
inlineprotectedvirtual |
Invoked if the last reference for a room is released and the room was removed from the cache. Can be overloaded by inheritors to provide a custom cleanup logic after a room has been disposed.
room | The Room that was removed from the cache. |
|
inline |
Releases a room reference. The related room instance will be removed from the cache if no more references to the room exists.
roomReference | The room reference to relaease. |
|
inline |
Tries to create a new room.
roomName | The room id. |
ownerPeer | The peer that holds this reference. |
roomReference | When this method returns true, contains a new RoomReference for the room with the specified room id; otherwise, set to null. |
args | Optionally arguments used for room creation. |
|
inline |
Tries to get room reference for a room with the specified id.
roomId | The room id. |
ownerPeer | The peer that holds this reference. |
roomReference | When this method returns true, contains a new RoomReference for the room with the specified room id; otherwise, set to null. |
|
inline |
Tries to get room reference for a room with the specified id, without holding a reference to that room.
roomId | The room id. |
room | The room, in case it exists. |
|
inline |
Tries to remove a romm instance from the room cache. The room will only be removed if there are no references to the romm instance left.
room | The room to remove. |
|
protected |
A Dictionary used to store room instances.
|
protected |
used to syncronize acces to the cache.