Interface Room

  • All Known Implementing Classes:
    MMORoom, SFSRoom

    public interface Room
    The Room interface defines all the methods and properties that an object representing a SmartFoxServer Room entity exposes.

    In the SmartFoxServer 2X client API this interface is implemented by the SFSRoom class. Read the class description for additional informations.

    See Also:
    SFSRoom
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void addUser​(User user)
      * API internal usage only *
      boolean containsUser​(User user)
      Indicates whether the specified user is currently inside this Room or not.
      boolean containsVariable​(java.lang.String name)
      Indicates whether this Room has the specified Room Variable set or not.
      int getCapacity()
      Returns the maximum amount of users, including spectators, that can be contained in this Room.
      java.lang.String getGroupId()
      Returns the Room Group name.
      int getId()
      Indicates the id of this Room.
      int getMaxSpectators()
      Returns the maximum number of spectators allowed in this Room (Game Rooms only).
      int getMaxUsers()
      Returns the maximum number of users allowed in this Room.
      java.lang.String getName()
      Indicates the name of this Room.
      java.util.List<User> getPlayerList()
      Returns a list of User objects representing the players currently inside this Room (Game Rooms only).
      java.util.Map<?,​?> getProperties()
      Defines a generic utility object that can be used to store custom Room data.
      IRoomManager getRoomManager()
      Returns a reference to the Room Manager which manages this Room.
      int getSpectatorCount()
      Returns the current number of spectators in this Room (Game Rooms only).
      java.util.List<User> getSpectatorList()
      Returns a list of User objects representing the spectators currently inside this Room (Game Rooms only).
      User getUserById​(int id)
      Retrieves a User object from its id property.
      User getUserByName​(java.lang.String name)
      Retrieves a User object from its name property.
      int getUserCount()
      Returns the current number of users in this Room.
      java.util.List<User> getUserList()
      Returns a list of User objects representing all the users currently inside this Room.
      RoomVariable getVariable​(java.lang.String name)
      Retrieves a Room Variable from its name.
      java.util.List<RoomVariable> getVariables()
      Retrieves all the Room Variables of this Room.
      boolean isGame()
      Indicates whether this is a Game Room or not.
      boolean isHidden()
      Indicates whether this Room is hidden or not.
      boolean isJoined()
      Indicates whether the client joined this Room or not.
      boolean isManaged()
      * API internal usage only *
      boolean isPasswordProtected()
      Indicates whether this Room requires a password to be joined or not.
      void merge​(Room anotherRoom)
      * API internal usage only *
      void removeUser​(User user)
      * API internal usage only *
      void setGame​(boolean game)
      * API internal usage only *
      void setHidden​(boolean hidden)
      * API internal usage only *
      void setJoined​(boolean joined)
      * API internal usage only *
      void setManaged​(boolean managed)
      * API internal usage only *
      void setMaxSpectators​(int maxSpectators)
      * API internal usage only *
      void setMaxUsers​(int maxUsers)
      * API internal usage only *
      void setName​(java.lang.String name)
      * API internal usage only *
      void setPasswordProtected​(boolean passwordProtected)
      * API internal usage only *
      void setProperties​(java.util.Map<?,​?> properties)
      Defines a generic utility object that can be used to store custom Room data.
      void setRoomManager​(IRoomManager manager)
      * API internal usage only *
      void setSpectatorCount​(int spectatorCount)
      * API internal usage only *
      void setUserCount​(int userCount)
      * API internal usage only *
      void setVariable​(RoomVariable roomVariable)
      * API internal usage only *
      void setVariables​(java.util.List<? extends RoomVariable> roomVariables)
      * API internal usage only *
    • Method Detail

      • getId

        int getId()
        Indicates the id of this Room. It is unique and it is generated by the server when the Room is created.
      • getName

        java.lang.String getName()
        Indicates the name of this Room. Two Rooms in the same Zone can't have the same name.

        NOTE: setting the name property manually has no effect on the server and can disrupt the API functioning. Use the ChangeRoomNameRequest request instead.

        See Also:
        ChangeRoomNameRequest
      • setName

        void setName​(java.lang.String name)
        * API internal usage only *
      • getGroupId

        java.lang.String getGroupId()
        Returns the Room Group name. Each Group is identified by a unique string (its name or id) and it represents a different "container" for Rooms.

        Room Groups enable developers to organize Rooms under different types or categories and let clients select only those Groups they are interested in, in order to receive their events only. This is done via the SubscribeRoomGroupRequest and UnsubscribeRoomGroupRequest requests.

        The default value is default.

        See Also:
        SubscribeRoomGroupRequest, UnsubscribeRoomGroupRequest
      • isJoined

        boolean isJoined()
        Indicates whether the client joined this Room or not.

        NOTE: setting the isJoined property manually has no effect on the server and can disrupt the API functioning. Use the JoinRoomRequest request to join a new Room instead.

        See Also:
        JoinRoomRequest
      • isGame

        boolean isGame()
        Indicates whether this is a Game Room or not.

        NOTE: setting the isGame property manually has no effect on the server and can disrupt the API functioning. This flag must be set when creating the Room.

      • isHidden

        boolean isHidden()
        Indicates whether this Room is hidden or not. This is a utility flag that can be used by developers to hide certain Rooms from the interface of their application.

        NOTE: setting the isHidden property manually has no effect on the server and can disrupt the API functioning. This flag must be set when creating the Room.

      • isPasswordProtected

        boolean isPasswordProtected()
        Indicates whether this Room requires a password to be joined or not.

        NOTE: setting the isPasswordProtected property manually has no effect on the server and can disrupt the API functioning. This flag depends on the Room's password set when the Room is created or by means of the ChangeRoomPasswordStateRequest request.

        See Also:
        ChangeRoomPasswordStateRequest
      • setPasswordProtected

        void setPasswordProtected​(boolean passwordProtected)
        * API internal usage only *
      • isManaged

        boolean isManaged()
        * API internal usage only *
      • getUserCount

        int getUserCount()
        Returns the current number of users in this Room. In case of Game Rooms, this is the number of players.

        NOTE: setting the userCount property manually has no effect on the server and can disrupt the API functioning. This flag depends on the Room state.

      • getMaxUsers

        int getMaxUsers()
        Returns the maximum number of users allowed in this Room. In case of Game Rooms, this is the maximum number of players.

        NOTE: setting the maxUsers property manually has no effect on the server and can disrupt the API functioning. This flag must be set when creating the Room.

      • getSpectatorCount

        int getSpectatorCount()
        Returns the current number of spectators in this Room (Game Rooms only).

        NOTE: setting the spectatorCount property manually has no effect on the server and can disrupt the API functioning. This flag depends on the Room state.

      • getMaxSpectators

        int getMaxSpectators()
        Returns the maximum number of spectators allowed in this Room (Game Rooms only).

        NOTE: setting the maxSpectators property manually has no effect on the server and can disrupt the API functioning. This flag must be set when creating the Game Room.

      • getCapacity

        int getCapacity()
        Returns the maximum amount of users, including spectators, that can be contained in this Room.
      • setJoined

        void setJoined​(boolean joined)
        * API internal usage only *
      • setGame

        void setGame​(boolean game)
        * API internal usage only *
      • setHidden

        void setHidden​(boolean hidden)
        * API internal usage only *
      • setManaged

        void setManaged​(boolean managed)
        * API internal usage only *
      • setUserCount

        void setUserCount​(int userCount)
        * API internal usage only *
      • setMaxUsers

        void setMaxUsers​(int maxUsers)
        * API internal usage only *
      • setSpectatorCount

        void setSpectatorCount​(int spectatorCount)
        * API internal usage only *
      • setMaxSpectators

        void setMaxSpectators​(int maxSpectators)
        * API internal usage only *
      • addUser

        void addUser​(User user)
        * API internal usage only *
      • removeUser

        void removeUser​(User user)
        * API internal usage only *
      • containsUser

        boolean containsUser​(User user)
        Indicates whether the specified user is currently inside this Room or not.
        Parameters:
        user - The User object representing the user whose presence in this Room must be checked.
        Returns:
        true if the user is inside this Room; false otherwise.
      • getUserByName

        User getUserByName​(java.lang.String name)
        Retrieves a User object from its name property.
        Parameters:
        name - The name of the user to be found.
        Returns:
        The User object representing the user, or null if no user with the passed name exists in this Room.
        See Also:
        getUserById(int)
      • getUserById

        User getUserById​(int id)
        Retrieves a User object from its id property.
        Parameters:
        id - The id of the user to be found.
        Returns:
        The User object representing the user, or null if no user with the passed id exists in this Room.
        See Also:
        getUserByName(String)
      • getUserList

        java.util.List<User> getUserList()
        Returns a list of User objects representing all the users currently inside this Room.
      • getPlayerList

        java.util.List<User> getPlayerList()
        Returns a list of User objects representing the players currently inside this Room (Game Rooms only).
      • getSpectatorList

        java.util.List<User> getSpectatorList()
        Returns a list of User objects representing the spectators currently inside this Room (Game Rooms only).
      • getVariable

        RoomVariable getVariable​(java.lang.String name)
        Retrieves a Room Variable from its name.
        Parameters:
        name - The name of the Room Variable to be retrieved.
        Returns:
        The RoomVariable object representing the Room Variable, or null if no Room Variable with the passed name exists in this Room.
        See Also:
        getVariables(), SetRoomVariablesRequest
      • getVariables

        java.util.List<RoomVariable> getVariables()
        Retrieves all the Room Variables of this Room.
        Returns:
        The list of RoomVariable objects associated with this Room.
        See Also:
        getVariable(String), RoomVariable
      • setVariable

        void setVariable​(RoomVariable roomVariable)
        * API internal usage only *
      • setVariables

        void setVariables​(java.util.List<? extends RoomVariable> roomVariables)
        * API internal usage only *
      • containsVariable

        boolean containsVariable​(java.lang.String name)
        Indicates whether this Room has the specified Room Variable set or not.
        Parameters:
        name - The name of the Room Variable whose existance in this Room must be checked.
        Returns:
        true if a Room Variable with the passed name exists in this Room.
      • getProperties

        java.util.Map<?,​?> getProperties()
        Defines a generic utility object that can be used to store custom Room data. The values added to this object are for client-side use only and are never transmitted to the server or to the other clients.
        See Also:
        setProperties(Map)
      • setProperties

        void setProperties​(java.util.Map<?,​?> properties)
        Defines a generic utility object that can be used to store custom Room data. The values added to this object are for client-side use only and are never transmitted to the server or to the other clients.
        See Also:
        getProperties()
      • getRoomManager

        IRoomManager getRoomManager()
        Returns a reference to the Room Manager which manages this Room.

        NOTE: setting the roomManager property manually has no effect on the server and can disrupt the API functioning.

      • setRoomManager

        void setRoomManager​(IRoomManager manager)
                     throws com.smartfoxserver.v2.exceptions.SFSException
        * API internal usage only *
        Throws:
        com.smartfoxserver.v2.exceptions.SFSException
      • merge

        void merge​(Room anotherRoom)
        * API internal usage only *