Class CreateRoomSettings

java.lang.Object
com.smartfoxserver.api.CreateRoomSettings
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
CreateMMORoomSettings, CreateSFSGameSettings

public class CreateRoomSettings extends Object implements Serializable
This class specifies the configuration of a Room that we want to create: from its name and user capacity, to the events it can triggers, to its permissions and lots more.

Basic Settings

A minimal Room configuration should contain the following parameters:
  • name: name of the Room, must be unique
  • password: (optional) a password if the Room is supposed to be private
  • maxUsers: the maximum number of Users allowed in the Room
  • maxVariablesAllowed: the maximum number of RoomVariable allowed for the Room
  • isGame: (optional) if the Room is going to be used for games this flag should be set to true
  • maxSpectators: (optional) the max number of spectators allowed, when the isGame flag is activated

More Settings

A few more advanced settings:
  • autoRemoveMode: toggles the auto-remove-mode which allows Rooms to be destroyed when appropriate
  • roomVariables: provide a list of RoomVariable that will be added to the Room
  • extension: dynamically attach a Server-Side extension to the Room, adding custom logic for your games

Advanced Settings

These allow to fine tune the Room behavior:
  • roomSettings: allow to specify permissions and events used by the Room.
  • badWordsFilter: configure the bad words filtering options
  • customPlayerIdGeneratorClass: provide a custom Class that handles the generation of playerId(s) for Game Rooms
See Also:
  • Constructor Details

    • CreateRoomSettings

      public CreateRoomSettings()
  • Method Details

    • getName

      public String getName()
      Get the name of the Room. Room names must be unique, although they are not cases-sensitive. In other words this means that a Room called "My House" will not collide with a Room called "MY HOUSE"
      Returns:
      the Room bame
    • setName

      public void setName(String name)
      Set the name of the Room. Room names must be unique, although they are not cases-sensitive. In other words this means that a Room called "My House" will not collide with a Room called "MY HOUSE"
      Parameters:
      name - the name of the new Room
    • getGroupId

      public String getGroupId()
      The name of the Room Group that the new Room will be assigned to.
      Returns:
      the group Id
    • setGroupId

      public void setGroupId(String groupId)
      Set the name of the Room Group that the new Room will be assigned to. A value of null will indicate the "default" Group. If the group doesn't exist it will be created (server side only)
      Parameters:
      groupId -
    • getPassword

      public String getPassword()
      Get the Room password.
      Returns:
      the Room password, or null if no password was assigned to the Room
    • setPassword

      public void setPassword(String password)
      Set the Room password
      Parameters:
      password - the password to join the Room
    • getMaxUsers

      public int getMaxUsers()
      Get the maximum number of users allowed in the Room
      Returns:
      the maximum number of users allowed in the Room
    • setMaxUsers

      public void setMaxUsers(int maxUsers)
      Set the maximum number of users allowed in the Room
      Parameters:
      maxUsers - the maximum number of users allowed in the Room
    • getMaxSpectators

      public int getMaxSpectators()
      Get the maximum number of spectators allowed in the Room (game only)
    • setMaxSpectators

      public void setMaxSpectators(int maxSpectators)
      Set the maximum number of spectators allowed in the Room (game only)
      Parameters:
      maxSpectators - the maximum number of spectators allowed in the Room
    • isDynamic

      public boolean isDynamic()
      A dynamic Room is created at runtime by either a client request or a server side "CreateRoom" command.

      NOTE: When the flag is turned off the Room is considered "static" and therefore never removed. In other words the AutoRemoveMode parameter will be ignored.

      Returns:
      true, if the Room was created dynamically.
    • setDynamic

      public void setDynamic(boolean isDynamic)
      Set the Room as dynamic. Dynamic Rooms can be auto-removed by the Room Manager according to the specified rules. Non-dynamic Room can only be removed manually either via code or from the Admin Tool.
      Parameters:
      isDynamic -
    • isGame

      public boolean isGame()
      Check if the Room is a game.
      Returns:
      true if the Room is a Game Room
    • setGame

      public void setGame(boolean isGame)
      Set the Room as a Game Room.
      Parameters:
      isGame -
    • isHidden

      public boolean isHidden()
      The hidden flag allows to conceal one or more Rooms from the Room List. Hidden Rooms are sent to the client with the initial Room List. The developer can detect the hidden flag and avoid to show them in the GUI.
      Returns:
      true if the Room is hidden
    • setHidden

      public void setHidden(boolean isHidden)
      Set the Room as hidden. Hidden Rooms are sent to the client with the initial Room List. The developer can detect the hidden flag and avoid to show them in the GUI.
      Parameters:
      isHidden -
    • getAutoRemoveMode

      public SFSRoomRemoveMode getAutoRemoveMode()
      Get the Auto-Remove mode of the Room
      Returns:
      the Auto-Remove modality
      See Also:
    • setAutoRemoveMode

      public void setAutoRemoveMode(SFSRoomRemoveMode autoRemoveMode)
      Set the Auto-Remove mode of the Room for a dynamic Room.

      Dynamic rooms can be auto-removed with different rules. Make sure the isDynamic flag is also turned on to activate the Auto-Remove.

      Parameters:
      autoRemoveMode - the Auto-Remove mode of the Room
      See Also:
    • getRoomSettings

      public Set<SFSRoomSettings> getRoomSettings()
      Get the advanced settings of the Room. These flags allow to configure which events the Room will broadcast and which operations are allowed in the Room itself.
      Returns:
      a Set of advanced Room settings (those present in the Set are active, those missing are inactive)
      See Also:
    • setRoomSettings

      public void setRoomSettings(Set<SFSRoomSettings> roomSettings)
      Set the advanced settings of the Room. These flags allow to configure which events the Room will broadcast and which operations are allowed in the Room itself.

      You can use the EnumSet.of() method to easily concatenate multiple flags in a one line expression.

      Parameters:
      roomSettings - a List of settings that are active.
      See Also:
    • isUseWordsFilter

      public 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

      public void setUseWordsFilter(boolean useWordsFilter)
      Toggle the word filter in this Room (applied to Public Messages)
      Parameters:
      useWordsFilter -
    • getRoomVariables

      public List<RoomVariable> getRoomVariables()
      Get the list of Room Variables for the new Room
      Returns:
      the list of Room Variables for the new Room
      See Also:
    • setRoomVariables

      public void setRoomVariables(List<RoomVariable> roomVariables)
      Set one or more Room Variables in the new Room
      Parameters:
      roomVariables - a list of Room Variables
      See Also:
    • getExtension

      Get the Extension attached to the Room
      Returns:
      the extension attached to the Room
      See Also:
    • setExtension

      public void setExtension(CreateRoomSettings.RoomExtensionSettings extension)
      Set the Extension for the Room
      Parameters:
      extension - the extension
      See Also:
    • getMaxVariablesAllowed

      public int getMaxVariablesAllowed()
      Get the maximum number of Room Variables allowed
      Returns:
      the maximum number of Room Variables allowed
    • setMaxVariablesAllowed

      public void setMaxVariablesAllowed(int maxVariablesAllowed)
      Set the maximum number of Room Variables allowed
      Parameters:
      maxVariablesAllowed - the maximum number of Room Variables allowed
    • getCustomPlayerIdGeneratorClass

      public Class<? extends IPlayerIdGenerator> getCustomPlayerIdGeneratorClass()
      Get the PlayerId Generator class.
      Returns:
      the player id generator
      See Also:
    • setCustomPlayerIdGeneratorClass

      public void setCustomPlayerIdGeneratorClass(Class<? extends IPlayerIdGenerator> customPlayerIdGeneratorClass)
      All Game Rooms by default use the SFS default PlayerId Generator class. Developers can specify their own implementation and override the default class.
      Parameters:
      customPlayerIdGeneratorClass - the custom PlayerId Generator implementation
      See Also:
    • getRoomProperties

      public Map<Object,Object> getRoomProperties()
      Get the custom properties attached to the Room object
      Returns:
      the custom properties
    • setRoomProperties

      public void setRoomProperties(Map<Object,Object> roomProperties)
      Allows to set a number of custom properties that will be available in the Room Extension
      Parameters:
      roomProperties - a map of custom properties
    • allowOwnerOnlyInvitation

      public boolean allowOwnerOnlyInvitation()
      If false, any User joined in the Room will be able to invite players in the Room. If true, only the creator is allowed. Default setting is true.

      NOTE: Users joined as spectators cannot invite other players

      Returns:
      false if any User joined in the Room can invite players in the Room. True if only the creator is allowed.
      See Also:
    • setAllowOwnerOnlyInvitation

      public void setAllowOwnerOnlyInvitation(boolean allowOwnerInvitation)
      If false, any User joined in the Room will be able to invite players in the Room. If true, only the creator is allowed. Default setting is true.

      NOTE: Users joined as spectators cannot invite other players

      Parameters:
      allowOwnerInvitation -
      See Also:
    • isSuppressUserList

      public boolean isSuppressUserList()
      Check whether or not the client side User list is suppressed for this Room
      Returns:
      true if the list is suppressed
    • setSuppressUserList

      public void setSuppressUserList(boolean value)
      Used to suppress the User list on the client side, for special use cases when Rooms are not used for User interaction.

      When set to true this will suppress the User list sent by the server on ROOM_JOIN event as well as the USER_ENTER and USER_EXIT events.

      NOTE: This is does not work with MMORooms.

      Parameters:
      value - true to suppress the User list and related update events (default = false)
    • allowAudioStreaming

      public boolean allowAudioStreaming()
      If true, audio streaming is allowed in the Room.
      Returns:
      true if audio streaming is allowed in the Room.
    • setAllowAudioStreaming

      public void setAllowAudioStreaming(boolean allowAudioStreaming)
      Allow/disallow audio streaming in the Room.
      Parameters:
      allowAudioStreaming -
    • toString

      public String toString()
      Overrides:
      toString in class Object