Package com.smartfoxserver.api
Class CreateRoomSettings
java.lang.Object
com.smartfoxserver.api.CreateRoomSettings
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
CreateMMORoomSettings,CreateSFSGameSettings
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
RoomVariableallowed 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
RoomVariablethat 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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classDefine the Extension settings of the Room -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanIf true, audio streaming is allowed in the Room.booleanIf false, any User joined in the Room will be able to invite players in the Room.Get the Auto-Remove mode of the RoomClass<? extends IPlayerIdGenerator> Get the PlayerId Generator class.Get the Extension attached to the RoomThe name of the Room Group that the new Room will be assigned to.intGet the maximum number of spectators allowed in the Room (game only)intGet the maximum number of users allowed in the RoomintGet the maximum number of Room Variables allowedgetName()Get the name of the Room.Get the Room password.Get the custom properties attached to the Room objectGet the advanced settings of the Room.Get the list of Room Variables for the new RoombooleanA dynamic Room is created at runtime by either a client request or a server side "CreateRoom" command.booleanisGame()Check if the Room is a game.booleanisHidden()The hidden flag allows to conceal one or more Rooms from the Room List.booleanCheck whether or not the client side User list is suppressed for this RoombooleanCheck if the word filter is used in this Room (applied to Public Messages)voidsetAllowAudioStreaming(boolean allowAudioStreaming) Allow/disallow audio streaming in the Room.voidsetAllowOwnerOnlyInvitation(boolean allowOwnerInvitation) If false, any User joined in the Room will be able to invite players in the Room.voidsetAutoRemoveMode(SFSRoomRemoveMode autoRemoveMode) Set the Auto-Remove mode of the Room for a dynamic Room.voidsetCustomPlayerIdGeneratorClass(Class<? extends IPlayerIdGenerator> customPlayerIdGeneratorClass) All Game Rooms by default use the SFS default PlayerId Generator class.voidsetDynamic(boolean isDynamic) Set the Room as dynamic.voidSet the Extension for the RoomvoidsetGame(boolean isGame) Set the Room as a Game Room.voidsetGroupId(String groupId) Set the name of the Room Group that the new Room will be assigned to.voidsetHidden(boolean isHidden) Set the Room as hidden.voidsetMaxSpectators(int maxSpectators) Set the maximum number of spectators allowed in the Room (game only)voidsetMaxUsers(int maxUsers) Set the maximum number of users allowed in the RoomvoidsetMaxVariablesAllowed(int maxVariablesAllowed) Set the maximum number of Room Variables allowedvoidSet the name of the Room.voidsetPassword(String password) Set the Room passwordvoidsetRoomProperties(Map<Object, Object> roomProperties) Allows to set a number of custom properties that will be available in the Room ExtensionvoidsetRoomSettings(Set<SFSRoomSettings> roomSettings) Set the advanced settings of the Room.voidsetRoomVariables(List<RoomVariable> roomVariables) Set one or more Room Variables in the new RoomvoidsetSuppressUserList(boolean value) Used to suppress the User list on the client side, for special use cases when Rooms are not used for User interaction.voidsetUseWordsFilter(boolean useWordsFilter) Toggle the word filter in this Room (applied to Public Messages)toString()
-
Constructor Details
-
CreateRoomSettings
public CreateRoomSettings()
-
-
Method Details
-
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
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
The name of the Room Group that the new Room will be assigned to.- Returns:
- the group Id
-
setGroupId
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
Get the Room password.- Returns:
- the Room password, or null if no password was assigned to the Room
-
setPassword
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
Get the Auto-Remove mode of the Room- Returns:
- the Auto-Remove modality
- See Also:
-
setAutoRemoveMode
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
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
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
Get the list of Room Variables for the new Room- Returns:
- the list of Room Variables for the new Room
- See Also:
-
setRoomVariables
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
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
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
Get the custom properties attached to the Room object- Returns:
- the custom properties
-
setRoomProperties
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
-