Interface Room

    • 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)
      • 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
      • 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
      • 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
      • 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 name
        value - 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)
      • 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)
      • 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)