Package com.smartfoxserver.entities
Interface Room
public interface Room
-
Method Summary
Modifier and TypeMethodDescriptionvoidvoidvoidbooleancontainsProperty(Object key) Checks whether a custom property exists or notbooleancontainsUser(User user) Checks if the specified User is joined in the RoombooleancontainsUser(String name) Checks if the specified User is joined in the RoombooleancontainsVariable(String varName) Checks if a certain Room Variable name existsvoiddestroy()voidcom.smartfoxserver.entities.managers.IAudioManagerReturn the auto-remove mode of the RoomReturns the id of every User currently banned in this Room.intReturn the capacity of the Room (maximum number of clients that can be contained).getDump()Get the extension connected to this Room, if anyGet the Room Group Id.intgetId()Return the unique Room IdlongObtain the time of existence of the RoomintReturn the maximum number of Room Variables allowed in the Room.intReturn the maximum number of Spectators allowed in the Room.intReturn the maximum number of Users allowed in the Room.getName()Get the room namegetOwner()Get the owner of the Room (the user that created it)Returns the name of user that created the Room.Get the Room password.For Game Rooms: get all Players in the Room (same as all User without the Spectators)Get the map with all Room propertiesgetProperty(Object key) Get any custom property attached to this Room.getRoomVariablesData(boolean globalsOnly) Get all the User Sessions in the RoomgetSize()Return the current Room sizeFor Game Rooms: get all Spectators in the Room (same as all User without the Players)getUserById(int id) getUserByName(String name) getUserByPlayerId(int playerId) Get the User currently having the specified playerId (Game Room only)getUserBySession(ISession session) Get all Users in the Roomcom.smartfoxserver.entities.managers.IUserManagergetVariable(String varName) Get a Room VariableGet the full list of Room Variables in the RoomintGet the total amount of Room Variables for this RoomGet a list of Room Variables created by a specific UsergetZone()Get the Zone managing this Room.booleanisActive()Return true if the Room is active in the Zone.booleanTrue if the Room allows only its creator to send JoinRoomInvitations.booleanReturns true if audio streaming is allowed in the current Room.booleanChecks if the Room was created dynamically (at runtime)booleanisEmpty()Checks whether the Room is emptybooleanisFlagSet(SFSRoomSettings flag) Checks whether a certain Room Setting is setbooleanisFull()Checks whether the Room is full.booleanisGame()Checks if this is a Game RoombooleanisHidden()Checks if the Game is hidden.booleanisJoinAllowed(User user) Returns false if the provided User is not allowed to join this Room.booleanReturn true if the Room is owned by the provided User object.booleanChecks if the Room requires a password for joining itbooleanisPublic()Returns true if the Room has public access, in other words it doesn't require a password.booleanbooleanCheck if the word filter is used in this Room (applied to Public Messages)voidremoveProperty(Object key) Removes a custom propertyvoidremoveUser(User user) voidremoveVariable(String varName) removeVariablesCreatedByUser(User user, boolean isLeaveRoom) voidsetActive(boolean flag) voidsetAllowOwnerInvitations(boolean flag) Set to true if the Room allows only its creator to send JoinRoomInvitations.voidvoidsetCapacity(int maxUser, int maxSpectators) voidsetDynamic(boolean b) voidsetExtension(ISFSExtension extension) voidsetFlag(SFSRoomSettings flag, boolean state) voidsetFlags(Set<SFSRoomSettings> settings) voidsetGame(boolean b) voidsetGame(boolean b, Class<? extends IPlayerIdGenerator> customPlayerIdGeneratorClass) voidsetGroupId(String group) voidsetHidden(boolean b) voidsetMaxRoomVariablesAllowed(int max) voidsetMaxSpectators(int max) voidsetMaxUsers(int max) voidvoidvoidsetPassword(String password) voidsetProperty(Object key, Object value) Attach a custom (server-side only) property to the Room objectvoidsetSuppressUserList(boolean value) voidsetUserManager(com.smartfoxserver.entities.managers.IUserManager manager) voidsetUseWordsFilter(boolean useWordsFilter) Toggle the word filter in this Room (applied to Public Messages)voidsetVariable(RoomVariable roomVariable) voidsetVariable(RoomVariable roomVariable, boolean overridOwnership) voidsetVariables(List<RoomVariable> variables) voidsetVariables(List<RoomVariable> variables, boolean overridOwnership) voidvoidswitchPlayerToSpectator(User user) voidswitchSpectatorToPlayer(User user) toSFSArray(boolean globalVarsOnly) void
-
Method Details
-
getId
int getId()Return the unique Room Id- Returns:
- the unique Room id
-
getGroupId
String getGroupId()Get the Room Group Id.- Returns:
- the group Id
-
setGroupId
- Internal
-
getName
String getName()Get the room name- Returns:
- the room name
-
setName
- Internal
-
getPassword
String getPassword()Get the Room password.- Returns:
- the room password, null if no password is used
- See Also:
-
setPassword
- Internal
-
isPasswordProtected
boolean isPasswordProtected()Checks if the Room requires a password for joining it- Returns:
- true if the Room requires a password
-
isPublic
boolean isPublic()Returns true if the Room has public access, in other words it doesn't require a password.- Returns:
- true id the Room is public and doesn't require a password
-
getCapacity
int getCapacity()Return the capacity of the Room (maximum number of clients that can be contained). In a Game Room this value is the sum of the maxUser + maxSpectators- Returns:
- the Room capacity
-
setCapacity
void setCapacity(int maxUser, int maxSpectators) - Internal
- Instead use
SFSApi.changeRoomCapacity(User, Room, int, int)
-
getMaxUsers
int getMaxUsers()Return the maximum number of Users allowed in the Room.- Returns:
- the max number of users allowed in the Room
-
setMaxUsers
void setMaxUsers(int max) - Internal
-
getMaxSpectators
int getMaxSpectators()Return the maximum number of Spectators allowed in the Room.- Returns:
- the max number of spectators allowed in the Room
-
setMaxSpectators
void setMaxSpectators(int max) - Internal
-
getMaxRoomVariablesAllowed
int getMaxRoomVariablesAllowed()Return the maximum number of Room Variables allowed in the Room.- Returns:
- the max number of Room Variables allowed in the Room
-
setMaxRoomVariablesAllowed
void setMaxRoomVariablesAllowed(int max) - Internal
-
getOwner
User getOwner()Get the owner of the Room (the user that created it)- Returns:
- the owner of the Room, it can be null if the Room was created by the Server itself
-
getOwnerName
String getOwnerName()Returns the name of user that created the Room.If the owner is the server itself the name will be "[server]"
- Returns:
-
isOwnedBy
Return true if the Room is owned by the provided User object.The owner of a Room is the User that created it. Rooms created by the server will always return false;
- Parameters:
user- the User to check- Returns:
- true if the Room is owned by the provided User object
-
setOwner
- Internal
-
getSize
RoomSize getSize()Return the current Room size- Returns:
- the current Room size
- See Also:
-
getUserManager
com.smartfoxserver.entities.managers.IUserManager getUserManager()- Internal
-
setUserManager
void setUserManager(com.smartfoxserver.entities.managers.IUserManager manager) - Internal
-
getAudioManager
com.smartfoxserver.entities.managers.IAudioManager getAudioManager()- Internal
-
enableAudioManager
void enableAudioManager()- Internal
-
isAudioStreamingAllowed
boolean isAudioStreamingAllowed()Returns true if audio streaming is allowed in the current Room.- Returns:
- true if audio streaming is allowed
-
banUser
- Internal
-
unbanUser
- Internal
-
isJoinAllowed
Returns false if the provided User is not allowed to join this Room. In such case the User must have been previously banned from this Room and the ban is not expired yet.- Parameters:
user- the User to check- Returns:
- false if the User is not allowed to join, true otherwise
-
getBannedUserIds
Collection<String> getBannedUserIds()Returns the id of every User currently banned in this Room.By default the 'user id' is the User's name, which is unique in the Zone. However certain application do not consistently associate the same User name to the same User when they login. For example, this happens when an email address is used for logging in rather than the user name. In those case the User name might be different on every Session and thus the banning system would not work.
- Returns:
- the User id (default is the user name)
-
getZone
Zone getZone()Get the Zone managing this Room.- Returns:
- the Zone that contains the Room
-
setZone
- Internal
-
isDynamic
boolean isDynamic()Checks if the Room was created dynamically (at runtime)- Returns:
- true if the Room was created dynamically
-
isGame
boolean isGame()Checks if this is a Game Room- Returns:
- true if this is a Game Room
-
isHidden
boolean isHidden()Checks if the Game is hidden. The hidden attribute doesn't change the Room normal behavior however it provides a flag that can be used on the client side to hide it from the Room List- Returns:
- true if the Room is 'hidden'
-
setDynamic
void setDynamic(boolean b) - Internal
-
setGame
void setGame(boolean b) - Internal
-
setGame
- Internal
-
setHidden
void setHidden(boolean b) - Internal
-
setFlags
- Internal
-
setFlag
- Internal
-
isFlagSet
Checks whether a certain Room Setting is set- Parameters:
flag- the flag- Returns:
- true if the flag is set
- See Also:
-
getAutoRemoveMode
SFSRoomRemoveMode getAutoRemoveMode()Return the auto-remove mode of the Room- Returns:
- the auto-remove mode of the Room
- See Also:
-
setAutoRemoveMode
-
isEmpty
boolean isEmpty()Checks whether the Room is empty- Returns:
- true if the Room is empty
-
isFull
boolean isFull()Checks whether the Room is full. In game rooms this check will return true only if all player slots are taken.- Returns:
- true if the Room is full
-
isActive
boolean isActive()Return true if the Room is active in the Zone. When a Room is not active it will refuse any join request- Returns:
- true if the Room is active
-
setActive
void setActive(boolean flag) - Internal
-
getExtension
ISFSExtension getExtension()Get the extension connected to this Room, if any- Returns:
- the extension attached to this Room, null if no extension exists
-
setExtension
- Internal
-
getVariable
Get a Room Variable- Parameters:
varName- the name of the variable- Returns:
- the variable
- See Also:
-
getVariables
List<RoomVariable> getVariables()Get the full list of Room Variables in the Room- Returns:
- the complete list of Room Variables in the Room
-
setVariable
- Throws:
SFSVariableException- Internal
-
setVariable
- Throws:
SFSVariableException- Internal
-
setVariables
- Internal
-
setVariables
- Internal
-
getVariablesCreatedByUser
Get a list of Room Variables created by a specific User- Parameters:
user- the User- Returns:
- list of Room Variables created by the provided User
-
removeVariablesCreatedByUser
- Internal
-
removeVariablesCreatedByUser
- Internal
-
removeVariable
-
containsVariable
Checks if a certain Room Variable name exists- Parameters:
varName- the variable name- Returns:
- true if a Room Variable with the provided name exists
-
getVariablesCount
int getVariablesCount()Get the total amount of Room Variables for this Room- Returns:
- the total amount of Room Variables for this Room
-
getProperty
Get any custom property attached to this Room.- Parameters:
key-- Returns:
- the value
-
getProperties
ConcurrentMap<Object,Object> getProperties()Get the map with all Room properties- Returns:
- the map with all User properties
-
setProperty
Attach a custom (server-side only) property to the Room object- Parameters:
key- the property namevalue- the property value
-
containsProperty
Checks whether a custom property exists or not- Parameters:
key- the name of the property- Returns:
- true if the property exists
-
removeProperty
Removes a custom property- Parameters:
key- the name of the property
-
getUserById
- Parameters:
id- the User id- Returns:
- the User with the provided id, null if no User was found in the Room
-
getUserByName
- Parameters:
name- the User name- Returns:
- the User with the provided name, null if no User was found in the Room
-
getUserBySession
- Parameters:
session- the User session- Returns:
- the User with the provided session, null if no User was found in the Room
-
getUserByPlayerId
Get the User currently having the specified playerId (Game Room only)- Parameters:
playerId- the player id- Returns:
- the User, null if no User exists with that player id
-
getUserList
Get all Users in the Room- Returns:
- all Users in the Room
-
getPlayersList
For Game Rooms: get all Players in the Room (same as all User without the Spectators)- Returns:
- all Players in the Room
-
getSpectatorsList
For Game Rooms: get all Spectators in the Room (same as all User without the Players)- Returns:
- all Spectators in the Room
-
getSessionList
Get all the User Sessions in the Room- Returns:
- all the User Sessions in the Room
-
getUserListData
ISFSArray getUserListData()- Internal
-
getRoomVariablesData
- Internal
-
addUser
- Throws:
SFSJoinRoomException- Internal
- Instead use
SFSApi.joinRoom(User, Room)
-
addUser
- Throws:
SFSJoinRoomException- Internal
- Instead use
SFSApi.joinRoom(User, Room)
-
removeUser
- Internal
- Instead use
SFSApi.leaveRoom(User, Room)
-
containsUser
Checks if the specified User is joined in the Room- Parameters:
user- the User- Returns:
- true if the User is present (joined) in this Room
-
containsUser
Checks if the specified User is joined in the Room- Parameters:
name- the User name- Returns:
- true if the User is present (joined) in this Room
-
toSFSArray
- Internal
-
switchPlayerToSpectator
- Throws:
SFSRoomException- Internal
- Instead use
SFSApi.playerToSpectator(User, Room, boolean, boolean)
-
switchSpectatorToPlayer
- Throws:
SFSRoomException- Internal
- Instead use
SFSApi.spectatorToPlayer(User, Room, boolean, boolean)
-
isUseWordsFilter
boolean isUseWordsFilter()Check if the word filter is used in this Room (applied to Public Messages)- Returns:
- true if the word filter is used in this Room (applied to Public Messages)
-
setUseWordsFilter
void setUseWordsFilter(boolean useWordsFilter) Toggle the word filter in this Room (applied to Public Messages)- Parameters:
useWordsFilter-
-
getLifeTime
long getLifeTime()Obtain the time of existence of the Room- Returns:
- the time of existence of the Room in milliseconds
-
getDump
String getDump()- Internal
-
destroy
void destroy()- Internal
-
getPlayerIdGeneratorClassName
String getPlayerIdGeneratorClassName()- Internal
-
isAllowOwnerInvitations
boolean isAllowOwnerInvitations()True if the Room allows only its creator to send JoinRoomInvitations. If false, any non spectator User joined in the Room can invite other people.- Returns:
- True if the Room allows only its creator to send JoinRoomInvitations. If false, any non spectator User joined in the Room can invite other people.
-
setAllowOwnerInvitations
void setAllowOwnerInvitations(boolean flag) Set to true if the Room allows only its creator to send JoinRoomInvitations. Use false if any non spectator User joined in the Room can invite other people.- Parameters:
flag- true if the Room allows only its creator to send JoinRoomInvitations. Use false if any non spectator User joined in the Room can invite other people.
-
isSuppressUserList
boolean isSuppressUserList()- Internal
-
setSuppressUserList
void setSuppressUserList(boolean value) - Internal
-