Package com.smartfoxserver.v2.entities
Interface Room
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddUser(User user)voidaddUser(User user, boolean asSpectator)booleancontainsProperty(java.lang.Object key)Checks whether a custom property exists or notbooleancontainsUser(User user)Checks if the specified User is joined in the RoombooleancontainsUser(java.lang.String name)Checks if the specified User is joined in the RoombooleancontainsVariable(java.lang.String varName)Checks if a certain Room Variable name existsvoiddestroy()SFSRoomRemoveModegetAutoRemoveMode()Return the auto-remove mode of the RoomintgetCapacity()Return the capacity of the Room (maximum number of clients that can be contained).java.lang.StringgetDump()Get a dump of all Room attributes/settings.ISFSExtensiongetExtension()Get the extension connected to this Room, if anyjava.lang.StringgetGroupId()Get the Room Group Id.intgetId()Return the unique Room IdlonggetLifeTime()Obtain the time of existence of the RoomintgetMaxRoomVariablesAllowed()Return the maximum number of Room Variables allowed in the Room.intgetMaxSpectators()Return the maximum number of Spectators allowed in the Room.intgetMaxUsers()Return the maximum number of Users allowed in the Room.java.lang.StringgetName()Get the room nameUsergetOwner()Get the owner of the Room (the user that created it)java.lang.StringgetPassword()Get the Room password.java.lang.StringgetPlayerIdGeneratorClassName()java.util.List<User>getPlayersList()For Game Rooms: get all Players in the Room (same as all User without the Spectators)java.util.concurrent.ConcurrentMap<java.lang.Object,java.lang.Object>getProperties()Get the map with all Room propertiesjava.lang.ObjectgetProperty(java.lang.Object key)Get any custom property attached to this Room.ISFSArraygetRoomVariablesData(boolean globalsOnly)java.util.List<ISession>getSessionList()Get all the User Sessions in the RoomRoomSizegetSize()Return the current Room sizejava.util.List<User>getSpectatorsList()For Game Rooms: get all Spectators in the Room (same as all User without the Players)UsergetUserById(int id)UsergetUserByName(java.lang.String name)UsergetUserByPlayerId(int playerId)Get the User currently having the specified playerId (Game Room only)UsergetUserBySession(ISession session)java.util.List<User>getUserList()Get all Users in the RoomISFSArraygetUserListData()com.smartfoxserver.v2.entities.managers.IUserManagergetUserManager()RoomVariablegetVariable(java.lang.String varName)Get a Room Variablejava.util.List<RoomVariable>getVariables()Get the full list of Room Variables in the RoomintgetVariablesCount()Get the total amount of Room Variables for this Roomjava.util.List<RoomVariable>getVariablesCreatedByUser(User user)Get a list of Room Variables created by a specific UserZonegetZone()Get the Zone managing this Room.booleanisActive()Return true if the Room is active in the Zone.booleanisAllowOwnerInvitations()True if the Room allows only its creator to send JoinRoomInvitations.booleanisDynamic()Checks 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.booleanisPasswordProtected()Checks 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.booleanisSuppressUserList()booleanisUseWordsFilter()Check if the word filter is used in this Room (applied to Public Messages)voidremoveProperty(java.lang.Object key)Removes a custom propertyvoidremoveUser(User user)voidremoveVariable(java.lang.String varName)java.util.List<RoomVariable>removeVariablesCreatedByUser(User user)java.util.List<RoomVariable>removeVariablesCreatedByUser(User user, boolean isLeaveRoom)voidsetActive(boolean flag)voidsetAllowOwnerInvitations(boolean flag)Set to true if the Room allows only its creator to send JoinRoomInvitations.voidsetAutoRemoveMode(SFSRoomRemoveMode mode)voidsetCapacity(int maxUser, int maxSpectators)voidsetDynamic(boolean b)voidsetExtension(ISFSExtension extension)voidsetFlag(SFSRoomSettings flag, boolean state)voidsetFlags(java.util.Set<SFSRoomSettings> settings)voidsetGame(boolean b)voidsetGame(boolean b, java.lang.Class<? extends IPlayerIdGenerator> customPlayerIdGeneratorClass)voidsetGroupId(java.lang.String group)voidsetHidden(boolean b)voidsetMaxRoomVariablesAllowed(int max)voidsetMaxSpectators(int max)voidsetMaxUsers(int max)voidsetName(java.lang.String name)voidsetOwner(User user)voidsetPassword(java.lang.String password)voidsetProperty(java.lang.Object key, java.lang.Object value)Attach a custom (server-side only) property to the Room objectvoidsetSuppressUserList(boolean value)voidsetUserManager(com.smartfoxserver.v2.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(java.util.List<RoomVariable> variables)voidsetVariables(java.util.List<RoomVariable> variables, boolean overridOwnership)voidsetZone(Zone zone)voidswitchPlayerToSpectator(User user)voidswitchSpectatorToPlayer(User user)ISFSArraytoSFSArray(boolean globalVarsOnly)
-
-
-
Method Detail
-
getId
int getId()
Return the unique Room Id- Returns:
- the unique Room id
-
getGroupId
java.lang.String getGroupId()
Get the Room Group Id.- Returns:
- the group Id
-
setGroupId
void setGroupId(java.lang.String group)
-
getName
java.lang.String getName()
Get the room name- Returns:
- the room name
-
setName
void setName(java.lang.String name)
-
getPassword
java.lang.String getPassword()
Get the Room password.- Returns:
- the room password, null if no password is used
- See Also:
isPasswordProtected()
-
setPassword
void setPassword(java.lang.String password)
-
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)
-
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)
-
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)
-
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)
-
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
-
setOwner
void setOwner(User user)
-
getSize
RoomSize getSize()
Return the current Room size- Returns:
- the current Room size
- See Also:
RoomSize
-
getUserManager
com.smartfoxserver.v2.entities.managers.IUserManager getUserManager()
-
setUserManager
void setUserManager(com.smartfoxserver.v2.entities.managers.IUserManager manager)
-
getZone
Zone getZone()
Get the Zone managing this Room.- Returns:
- the Zone that contains the Room
-
setZone
void setZone(Zone zone)
-
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)
-
setGame
void setGame(boolean b)
-
setGame
void setGame(boolean b, java.lang.Class<? extends IPlayerIdGenerator> customPlayerIdGeneratorClass)
-
setHidden
void setHidden(boolean b)
-
setFlags
void setFlags(java.util.Set<SFSRoomSettings> settings)
-
setFlag
void setFlag(SFSRoomSettings flag, boolean state)
-
isFlagSet
boolean isFlagSet(SFSRoomSettings flag)
Checks whether a certain Room Setting is set- Parameters:
flag- the flag- Returns:
- true if the flag is set
- See Also:
SFSRoomSettings
-
getAutoRemoveMode
SFSRoomRemoveMode getAutoRemoveMode()
Return the auto-remove mode of the Room- Returns:
- the auto-remove mode of the Room
- See Also:
SFSRoomRemoveMode
-
setAutoRemoveMode
void setAutoRemoveMode(SFSRoomRemoveMode mode)
-
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)
-
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
void setExtension(ISFSExtension extension)
-
getVariable
RoomVariable getVariable(java.lang.String varName)
Get a Room Variable- Parameters:
varName- the name of the variable- Returns:
- the variable
- See Also:
SFSRoomVariable
-
getVariables
java.util.List<RoomVariable> getVariables()
Get the full list of Room Variables in the Room- Returns:
- the complete list of Room Variables in the Room
-
setVariable
void setVariable(RoomVariable roomVariable, boolean overridOwnership) throws SFSVariableException
- Throws:
SFSVariableException
-
setVariable
void setVariable(RoomVariable roomVariable) throws SFSVariableException
- Throws:
SFSVariableException
-
setVariables
void setVariables(java.util.List<RoomVariable> variables, boolean overridOwnership)
-
setVariables
void setVariables(java.util.List<RoomVariable> variables)
-
getVariablesCreatedByUser
java.util.List<RoomVariable> getVariablesCreatedByUser(User user)
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
java.util.List<RoomVariable> removeVariablesCreatedByUser(User user)
-
removeVariablesCreatedByUser
java.util.List<RoomVariable> removeVariablesCreatedByUser(User user, boolean isLeaveRoom)
-
removeVariable
void removeVariable(java.lang.String varName)
-
containsVariable
boolean containsVariable(java.lang.String varName)
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
java.lang.Object getProperty(java.lang.Object key)
Get any custom property attached to this Room.- Parameters:
key-- Returns:
- the value
-
getProperties
java.util.concurrent.ConcurrentMap<java.lang.Object,java.lang.Object> getProperties()
Get the map with all Room properties- Returns:
- the map with all User properties
-
setProperty
void setProperty(java.lang.Object key, java.lang.Object value)Attach a custom (server-side only) property to the Room object- Parameters:
key- the property namevalue- the property value
-
containsProperty
boolean containsProperty(java.lang.Object key)
Checks whether a custom property exists or not- Parameters:
key- the name of the property- Returns:
- true if the property exists
-
removeProperty
void removeProperty(java.lang.Object key)
Removes a custom property- Parameters:
key- the name of the property
-
getUserById
User getUserById(int id)
- Parameters:
id- the User id- Returns:
- the User with the provided id, null if no User was found in the Room
-
getUserByName
User getUserByName(java.lang.String name)
- Parameters:
name- the User name- Returns:
- the User with the provided name, null if no User was found in the Room
-
getUserBySession
User getUserBySession(ISession session)
- Parameters:
session- the User session- Returns:
- the User with the provided session, null if no User was found in the Room
-
getUserByPlayerId
User getUserByPlayerId(int playerId)
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
java.util.List<User> getUserList()
Get all Users in the Room- Returns:
- all Users in the Room
-
getPlayersList
java.util.List<User> getPlayersList()
For Game Rooms: get all Players in the Room (same as all User without the Spectators)- Returns:
- all Players in the Room
-
getSpectatorsList
java.util.List<User> getSpectatorsList()
For Game Rooms: get all Spectators in the Room (same as all User without the Players)- Returns:
- all Spectators in the Room
-
getSessionList
java.util.List<ISession> getSessionList()
Get all the User Sessions in the Room- Returns:
- all the User Sessions in the Room
-
getUserListData
ISFSArray getUserListData()
-
getRoomVariablesData
ISFSArray getRoomVariablesData(boolean globalsOnly)
-
addUser
void addUser(User user, boolean asSpectator) throws SFSJoinRoomException
- Throws:
SFSJoinRoomException
-
addUser
void addUser(User user) throws SFSJoinRoomException
- Throws:
SFSJoinRoomException
-
removeUser
void removeUser(User user)
-
containsUser
boolean containsUser(User user)
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
boolean containsUser(java.lang.String name)
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
ISFSArray toSFSArray(boolean globalVarsOnly)
-
switchPlayerToSpectator
void switchPlayerToSpectator(User user) throws SFSRoomException
- Throws:
SFSRoomException
-
switchSpectatorToPlayer
void switchSpectatorToPlayer(User user) throws SFSRoomException
- Throws:
SFSRoomException
-
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
java.lang.String getDump()
Get a dump of all Room attributes/settings. Useful for debugging- Returns:
- a dump of all Room attributes/settings
-
destroy
void destroy()
-
getPlayerIdGeneratorClassName
java.lang.String getPlayerIdGeneratorClassName()
-
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.
- Since:
- 2.12
-
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.- Since:
- 2.12
-
isSuppressUserList
boolean isSuppressUserList()
-
setSuppressUserList
void setSuppressUserList(boolean value)
-
-