Interface IRoomStorage
-
public interface IRoomStorage
Basic interface for Room Storage implementations.The Room Persistence API provide a way of storing Rooms and their relative states (Room Variables) to disk or database. The API can be accessed via Extensions from the Zone object, using
Zone.getRoomPersistenceApi()
Example:
// Init method of a Zone Extension public void init() { //Initialize Persistence API getParentZone().initRoomPersistence(RoomStorageMode.FILE_STORAGE, new FileRoomStorageConfig()); // Load all previously stored Rooms try { getParentZone().getRoomPersistenceApi().loadAllRooms(); } catch (SFSStorageException error) { trace("Error loading rooms: " + error); } }
- Since:
- 2.8.0
- See Also:
DBRoomStorage
,FileRoomStorage
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
destroy()
Invoked by the system when the Storage class is being removed The method is your last chance to release open resources such as local files, database connections etc...void
init(Zone zone, BaseStorageConfig cfg)
Invoked once after the class is instantiated, it provides the reference to the current Zone and the custom configuratorjava.util.List<CreateRoomSettings>
loadAllRooms()
Load all stored Rooms for this Zonejava.util.List<CreateRoomSettings>
loadAllRooms(java.lang.String groupId)
Load all Rooms belonging to a specific Room GroupCreateRoomSettings
loadRoom(java.lang.String name)
Loads the setting of a previously saved Roomvoid
removeAllRooms()
Remove all stored Rooms for this Zone from the storage system (Use wisely!)void
removeAllRooms(java.lang.String groupId)
Remove all stored Rooms belonging to a specific Room Groupvoid
removeRoom(java.lang.String name)
Remove a saved Room from the storage systemvoid
saveAllRooms()
Saves all Rooms in the Zonevoid
saveAllRooms(java.lang.String groupId)
Saves all Rooms belonging to the provided group namevoid
saveRoom(Room theRoom)
Save a Room and its state
-
-
-
Method Detail
-
saveRoom
void saveRoom(Room theRoom) throws SFSStorageException
Save a Room and its state- Parameters:
theRoom
- a reference to a Room- Throws:
SFSStorageException
-
saveAllRooms
void saveAllRooms() throws SFSStorageException
Saves all Rooms in the Zone- Throws:
SFSStorageException
-
saveAllRooms
void saveAllRooms(java.lang.String groupId) throws SFSStorageException
Saves all Rooms belonging to the provided group name- Parameters:
groupId
- the group name- Throws:
SFSStorageException
-
loadRoom
CreateRoomSettings loadRoom(java.lang.String name) throws SFSStorageException
Loads the setting of a previously saved Room- Parameters:
name
- the name of the stored Room- Returns:
- the settings object with which the Room can be recreated in the system
- Throws:
SFSStorageException
- See Also:
CreateRoomSettings
,SFSApi.createRoom(com.smartfoxserver.v2.entities.Zone, CreateRoomSettings, com.smartfoxserver.v2.entities.User)
-
loadAllRooms
java.util.List<CreateRoomSettings> loadAllRooms() throws SFSStorageException
Load all stored Rooms for this Zone- Returns:
- A list of settings objects
- Throws:
SFSStorageException
- See Also:
CreateRoomSettings
,SFSApi.createRoom(com.smartfoxserver.v2.entities.Zone, CreateRoomSettings, com.smartfoxserver.v2.entities.User)
-
loadAllRooms
java.util.List<CreateRoomSettings> loadAllRooms(java.lang.String groupId) throws SFSStorageException
Load all Rooms belonging to a specific Room Group- Parameters:
groupId
- the Room Group name- Returns:
- A list of settings objects
- Throws:
SFSStorageException
- See Also:
CreateRoomSettings
,SFSApi.createRoom(com.smartfoxserver.v2.entities.Zone, CreateRoomSettings, com.smartfoxserver.v2.entities.User)
-
removeRoom
void removeRoom(java.lang.String name) throws SFSStorageException
Remove a saved Room from the storage system- Parameters:
name
- the name of the Room- Throws:
SFSStorageException
-
removeAllRooms
void removeAllRooms() throws SFSStorageException
Remove all stored Rooms for this Zone from the storage system (Use wisely!)- Throws:
SFSStorageException
-
removeAllRooms
void removeAllRooms(java.lang.String groupId) throws SFSStorageException
Remove all stored Rooms belonging to a specific Room Group- Parameters:
groupId
- the name of the Room Group- Throws:
SFSStorageException
-
destroy
void destroy()
Invoked by the system when the Storage class is being removed The method is your last chance to release open resources such as local files, database connections etc...
-
init
void init(Zone zone, BaseStorageConfig cfg)
Invoked once after the class is instantiated, it provides the reference to the current Zone and the custom configurator- Parameters:
zone
- The parent Zonecfg
- The custom configuration for your IRoomStorage implementation- See Also:
IRoomStorage
,Zone
-
-