Package com.smartfoxserver.v2.api
Class CreateRoomSettings
- java.lang.Object
-
- com.smartfoxserver.v2.api.CreateRoomSettings
-
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
CreateMMORoomSettings
,CreateSFSGameSettings
public class CreateRoomSettings extends java.lang.Object implements java.io.Serializable
The Room Settings allow you to configure how a new Room will work under many different aspects, from its size to the events it can fire, permissions and a lot more.Basic Settings
A minimal Room configuration should always contain the following parameters:- name: the name of the Room, must be unique
- password: (optional) a password should be specified for private Rooms
- maxUsers: the maximum number of Users allowed in the Room
- maxVariablesAllowed: the maximum number of
RoomVariable
allowed in the Room - isGame: (optional) if the Room is going to be used for games this flag should be set to true
- maxSpectators: (optional) if this is a Game Room you should configure how many spectators are allowed inside
More Settings
The following settings will help you define other important features of a Room- autoRemoveMode: turns on/off 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
The following settings will help you define the advanced aspects of each Room- 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:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CreateRoomSettings.RoomExtensionSettings
Define the Extension settings of the Room
-
Constructor Summary
Constructors Constructor Description CreateRoomSettings()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
allowOwnerOnlyInvitation()
If false, any User joined in the Room will be able to invite players in the Room.SFSRoomRemoveMode
getAutoRemoveMode()
Get the Auto-Remove mode of the Roomjava.lang.Class<? extends IPlayerIdGenerator>
getCustomPlayerIdGeneratorClass()
Get the PlayerId Generator class.CreateRoomSettings.RoomExtensionSettings
getExtension()
Get the Extension attached to the Roomjava.lang.String
getGroupId()
The name of the Room Group that the new Room will be assigned to.int
getMaxSpectators()
Get the maximum number of spectators allowed in the Room (game only)int
getMaxUsers()
Get the maximum number of users allowed in the Roomint
getMaxVariablesAllowed()
Get the maximum number of Room Variables allowedjava.lang.String
getName()
Get the name of the Room.java.lang.String
getPassword()
Get the Room password.java.util.Map<java.lang.Object,java.lang.Object>
getRoomProperties()
Get the custom properties attached to the Room objectjava.util.Set<SFSRoomSettings>
getRoomSettings()
Get the advanced settings of the Room.java.util.List<RoomVariable>
getRoomVariables()
Get the list of Room Variables for the new Roomboolean
isDynamic()
A dynamic Room is created at runtime by either a client request or a server side "CreateRoom" command.boolean
isGame()
Check if the Room is a game.boolean
isHidden()
The hidden flag allows to conceal one or more Rooms from the Room List.boolean
isSuppressUserList()
Check whether or not the client side User list is suppressed for this Roomboolean
isUseWordsFilter()
Check if the word filter is used in this Room (applied to Public Messages)void
setAllowOwnerOnlyInvitation(boolean allowOwnerInvitation)
If false, any User joined in the Room will be able to invite players in the Room.void
setAutoRemoveMode(SFSRoomRemoveMode autoRemoveMode)
Set the Auto-Remove mode of the Room for a dynamic Room.void
setCustomPlayerIdGeneratorClass(java.lang.Class<? extends IPlayerIdGenerator> customPlayerIdGeneratorClass)
All Game Rooms by default use the SFS2X default PlayerId Generator class.void
setDynamic(boolean isDynamic)
Set the Room as dynamic.void
setExtension(CreateRoomSettings.RoomExtensionSettings extension)
Set the Extension for the Roomvoid
setGame(boolean isGame)
Set the Room as a Game Room.void
setGroupId(java.lang.String groupId)
Set the name of the Room Group that the new Room will be assigned to.void
setHidden(boolean isHidden)
Set the Room as hidden.void
setMaxSpectators(int maxSpectators)
Set the maximum number of spectators allowed in the Room (game only)void
setMaxUsers(int maxUsers)
Set the maximum number of users allowed in the Roomvoid
setMaxVariablesAllowed(int maxVariablesAllowed)
Set the maximum number of Room Variables allowedvoid
setName(java.lang.String name)
Set the name of the Room.void
setPassword(java.lang.String password)
Set the Room passwordvoid
setRoomProperties(java.util.Map<java.lang.Object,java.lang.Object> roomProperties)
Allows to set a number of custom properties that will be available in the Room Extensionvoid
setRoomSettings(java.util.Set<SFSRoomSettings> roomSettings)
Set the advanced settings of the Room.void
setRoomVariables(java.util.List<RoomVariable> roomVariables)
Set one or more Room Variables in the new Roomvoid
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.void
setUseWordsFilter(boolean useWordsFilter)
Toggle the word filter in this Room (applied to Public Messages)java.lang.String
toString()
-
-
-
Method Detail
-
getName
public java.lang.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(java.lang.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 java.lang.String getGroupId()
The name of the Room Group that the new Room will be assigned to.- Returns:
- the group Id
-
setGroupId
public void setGroupId(java.lang.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 java.lang.String getPassword()
Get the Room password.- Returns:
- the Room password, or null if no password was assigned to the Room
-
setPassword
public void setPassword(java.lang.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:
SFSRoomRemoveMode
-
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:
SFSRoomRemoveMode
,setDynamic(boolean)
-
getRoomSettings
public java.util.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:
SFSRoomSettings
-
setRoomSettings
public void setRoomSettings(java.util.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:
EnumSet.of(Enum)
-
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 java.util.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:
SFSRoomVariable
-
setRoomVariables
public void setRoomVariables(java.util.List<RoomVariable> roomVariables)
Set one or more Room Variables in the new Room- Parameters:
roomVariables
- a list of Room Variables- See Also:
SFSRoomVariable
-
getExtension
public CreateRoomSettings.RoomExtensionSettings getExtension()
Get the Extension attached to the Room- Returns:
- the extension attached to the Room
- See Also:
BaseSFSExtension
,SFSExtension
-
setExtension
public void setExtension(CreateRoomSettings.RoomExtensionSettings extension)
Set the Extension for the Room- Parameters:
extension
- the extension- See Also:
BaseSFSExtension
,SFSExtension
-
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 java.lang.Class<? extends IPlayerIdGenerator> getCustomPlayerIdGeneratorClass()
Get the PlayerId Generator class.- Returns:
- the player id generator
- See Also:
IPlayerIdGenerator
-
setCustomPlayerIdGeneratorClass
public void setCustomPlayerIdGeneratorClass(java.lang.Class<? extends IPlayerIdGenerator> customPlayerIdGeneratorClass)
All Game Rooms by default use the SFS2X default PlayerId Generator class. Developers can specify their own implementation and override the default class.- Parameters:
customPlayerIdGeneratorClass
- the custom PlayerId Generator implementation- See Also:
IPlayerIdGenerator
-
getRoomProperties
public java.util.Map<java.lang.Object,java.lang.Object> getRoomProperties()
Get the custom properties attached to the Room object- Returns:
- the custom properties
- Since:
- 2.8.0
-
setRoomProperties
public void setRoomProperties(java.util.Map<java.lang.Object,java.lang.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.
- Since:
- 2.12.0
- See Also:
SFSGameApi.sendJoinRoomInvitation(com.smartfoxserver.v2.entities.Room, com.smartfoxserver.v2.entities.User, List, int)
-
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
-- Since:
- 2.12.0
- See Also:
SFSGameApi.sendJoinRoomInvitation(com.smartfoxserver.v2.entities.Room, com.smartfoxserver.v2.entities.User, List, int)
-
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)- Since:
- 2.18.2
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-