Interface Room

All Known Implementing Classes:
MMORoom, SFSGame, SFSRoom

public interface Room
  • 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

      void setGroupId(String group)
      Internal
    • getName

      String getName()
      Get the room name
      Returns:
      the room name
    • setName

      void setName(String name)
      Internal
    • getPassword

      String getPassword()
      Get the Room password.
      Returns:
      the room password, null if no password is used
      See Also:
    • setPassword

      void setPassword(String password)
      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

      boolean isOwnedBy(User user)
      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

      void setOwner(User user)
      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

      void banUser(User user, int timeInterval, TimeUnit timeUnit)
      Internal
    • unbanUser

      void unbanUser(User user)
      Internal
    • isJoinAllowed

      boolean isJoinAllowed(User user)
      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

      void setZone(Zone zone)
      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

      void setGame(boolean b, Class<? extends IPlayerIdGenerator> customPlayerIdGeneratorClass)
      Internal
    • setHidden

      void setHidden(boolean b)
      Internal
    • setFlags

      void setFlags(Set<SFSRoomSettings> settings)
      Internal
    • setFlag

      void setFlag(SFSRoomSettings flag, boolean state)
      Internal
    • 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:
    • getAutoRemoveMode

      SFSRoomRemoveMode getAutoRemoveMode()
      Return the auto-remove mode of the Room
      Returns:
      the auto-remove mode of the Room
      See Also:
    • 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)
      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

      void setExtension(ISFSExtension extension)
      Internal
    • getVariable

      RoomVariable getVariable(String varName)
      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

      void setVariable(RoomVariable roomVariable, boolean overridOwnership) throws SFSVariableException
      Throws:
      SFSVariableException
      Internal
    • setVariable

      void setVariable(RoomVariable roomVariable) throws SFSVariableException
      Throws:
      SFSVariableException
      Internal
    • setVariables

      void setVariables(List<RoomVariable> variables, boolean overridOwnership)
      Internal
    • setVariables

      void setVariables(List<RoomVariable> variables)
      Internal
    • getVariablesCreatedByUser

      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

      List<RoomVariable> removeVariablesCreatedByUser(User user)
      Internal
    • removeVariablesCreatedByUser

      List<RoomVariable> removeVariablesCreatedByUser(User user, boolean isLeaveRoom)
      Internal
    • removeVariable

      void removeVariable(String varName)
    • containsVariable

      boolean containsVariable(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

      Object getProperty(Object key)
      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

      void setProperty(Object key, 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(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(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(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

      List<User> getUserList()
      Get all Users in the Room
      Returns:
      all Users in the Room
    • getPlayersList

      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

      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

      List<ISession> getSessionList()
      Get all the User Sessions in the Room
      Returns:
      all the User Sessions in the Room
    • getUserListData

      ISFSArray getUserListData()
      Internal
    • getRoomVariablesData

      ISFSArray getRoomVariablesData(boolean globalsOnly)
      Internal
    • addUser

      void addUser(User user, boolean asSpectator) throws SFSJoinRoomException
      Throws:
      SFSJoinRoomException
      Internal
      Instead use SFSApi.joinRoom(User, Room)
    • addUser

      void addUser(User user) throws SFSJoinRoomException
      Throws:
      SFSJoinRoomException
      Internal
      Instead use SFSApi.joinRoom(User, Room)
    • removeUser

      void removeUser(User user)
      Internal
      Instead use SFSApi.leaveRoom(User, Room)
    • 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(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)
      Internal
    • switchPlayerToSpectator

      void switchPlayerToSpectator(User user) throws SFSRoomException
      Throws:
      SFSRoomException
      Internal
      Instead use SFSApi.playerToSpectator(User, Room, boolean, boolean)
    • switchSpectatorToPlayer

      void switchSpectatorToPlayer(User user) throws SFSRoomException
      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