Package com.smartfoxserver.v2.entities
Interface Room
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addUser(User user)
void
addUser(User user, boolean asSpectator)
boolean
containsProperty(java.lang.Object key)
Checks whether a custom property exists or notboolean
containsUser(User user)
Checks if the specified User is joined in the Roomboolean
containsUser(java.lang.String name)
Checks if the specified User is joined in the Roomboolean
containsVariable(java.lang.String varName)
Checks if a certain Room Variable name existsvoid
destroy()
SFSRoomRemoveMode
getAutoRemoveMode()
Return the auto-remove mode of the Roomint
getCapacity()
Return the capacity of the Room (maximum number of clients that can be contained).java.lang.String
getDump()
Get a dump of all Room attributes/settings.ISFSExtension
getExtension()
Get the extension connected to this Room, if anyjava.lang.String
getGroupId()
Get the Room Group Id.int
getId()
Return the unique Room Idlong
getLifeTime()
Obtain the time of existence of the Roomint
getMaxRoomVariablesAllowed()
Return the maximum number of Room Variables allowed in the Room.int
getMaxSpectators()
Return the maximum number of Spectators allowed in the Room.int
getMaxUsers()
Return the maximum number of Users allowed in the Room.java.lang.String
getName()
Get the room nameUser
getOwner()
Get the owner of the Room (the user that created it)java.lang.String
getPassword()
Get the Room password.java.lang.String
getPlayerIdGeneratorClassName()
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.Object
getProperty(java.lang.Object key)
Get any custom property attached to this Room.ISFSArray
getRoomVariablesData(boolean globalsOnly)
java.util.List<ISession>
getSessionList()
Get all the User Sessions in the RoomRoomSize
getSize()
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)User
getUserById(int id)
User
getUserByName(java.lang.String name)
User
getUserByPlayerId(int playerId)
Get the User currently having the specified playerId (Game Room only)User
getUserBySession(ISession session)
java.util.List<User>
getUserList()
Get all Users in the RoomISFSArray
getUserListData()
com.smartfoxserver.v2.entities.managers.IUserManager
getUserManager()
RoomVariable
getVariable(java.lang.String varName)
Get a Room Variablejava.util.List<RoomVariable>
getVariables()
Get the full list of Room Variables in the Roomint
getVariablesCount()
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 UserZone
getZone()
Get the Zone managing this Room.boolean
isActive()
Return true if the Room is active in the Zone.boolean
isAllowOwnerInvitations()
True if the Room allows only its creator to send JoinRoomInvitations.boolean
isDynamic()
Checks if the Room was created dynamically (at runtime)boolean
isEmpty()
Checks whether the Room is emptyboolean
isFlagSet(SFSRoomSettings flag)
Checks whether a certain Room Setting is setboolean
isFull()
Checks whether the Room is full.boolean
isGame()
Checks if this is a Game Roomboolean
isHidden()
Checks if the Game is hidden.boolean
isPasswordProtected()
Checks if the Room requires a password for joining itboolean
isPublic()
Returns true if the Room has public access, in other words it doesn't require a password.boolean
isSuppressUserList()
boolean
isUseWordsFilter()
Check if the word filter is used in this Room (applied to Public Messages)void
removeProperty(java.lang.Object key)
Removes a custom propertyvoid
removeUser(User user)
void
removeVariable(java.lang.String varName)
java.util.List<RoomVariable>
removeVariablesCreatedByUser(User user)
java.util.List<RoomVariable>
removeVariablesCreatedByUser(User user, boolean isLeaveRoom)
void
setActive(boolean flag)
void
setAllowOwnerInvitations(boolean flag)
Set to true if the Room allows only its creator to send JoinRoomInvitations.void
setAutoRemoveMode(SFSRoomRemoveMode mode)
void
setCapacity(int maxUser, int maxSpectators)
void
setDynamic(boolean b)
void
setExtension(ISFSExtension extension)
void
setFlag(SFSRoomSettings flag, boolean state)
void
setFlags(java.util.Set<SFSRoomSettings> settings)
void
setGame(boolean b)
void
setGame(boolean b, java.lang.Class<? extends IPlayerIdGenerator> customPlayerIdGeneratorClass)
void
setGroupId(java.lang.String group)
void
setHidden(boolean b)
void
setMaxRoomVariablesAllowed(int max)
void
setMaxSpectators(int max)
void
setMaxUsers(int max)
void
setName(java.lang.String name)
void
setOwner(User user)
void
setPassword(java.lang.String password)
void
setProperty(java.lang.Object key, java.lang.Object value)
Attach a custom (server-side only) property to the Room objectvoid
setSuppressUserList(boolean value)
void
setUserManager(com.smartfoxserver.v2.entities.managers.IUserManager manager)
void
setUseWordsFilter(boolean useWordsFilter)
Toggle the word filter in this Room (applied to Public Messages)void
setVariable(RoomVariable roomVariable)
void
setVariable(RoomVariable roomVariable, boolean overridOwnership)
void
setVariables(java.util.List<RoomVariable> variables)
void
setVariables(java.util.List<RoomVariable> variables, boolean overridOwnership)
void
setZone(Zone zone)
void
switchPlayerToSpectator(User user)
void
switchSpectatorToPlayer(User user)
ISFSArray
toSFSArray(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)
-
-