Class SFSZone
- java.lang.Object
-
- com.smartfoxserver.v2.entities.SFSZone
-
- All Implemented Interfaces:
Zone
public final class SFSZone extends java.lang.Object implements Zone
Overview
The Zone represent an application running in the Server, from a simple chat application to a large scale MMO with dozens of games. Each Zone can contain any number of Rooms organized in Room Groups.Also each Zone provides a number of essential services:
- Room and User management
- Persistent BuddyList system
- Words filtering
- Flood filtering
- Database connection management and pooling
- Event dispatching
- Room persistence
- See Also:
Room
,SFSApi
,BaseSFSExtension
,SFSExtension
-
-
Field Summary
Fields Modifier and Type Field Description boolean
lagMonitorKeepAlive
-
Constructor Summary
Constructors Constructor Description SFSZone(java.lang.String name)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addDisabledSystemEvent(java.lang.String eventID)
INTERNALvoid
addRoom(Room room)
INTERNALvoid
changeRoomCapacity(Room room, int newMaxUsers, int newMaxSpect)
void
changeRoomName(Room room, java.lang.String newName)
void
changeRoomPasswordState(Room room, java.lang.String password)
void
checkAndRemove(Room room)
boolean
containsGroup(java.lang.String groupId)
Check if the Zone contains the specified Groupboolean
containsProperty(java.lang.Object key)
Checks the existance of a Zone propertyboolean
containsPublicGroup(java.lang.String groupId)
Check if the Zone contains the specified public GroupRoom
createRoom(CreateRoomSettings params)
Use theSFSApi.createRoom(Zone, CreateRoomSettings, User)
method insteadRoom
createRoom(CreateRoomSettings params, User user)
Use theSFSApi.createRoom(Zone, CreateRoomSettings, User)
method insteadcom.smartfoxserver.v2.util.IAdminHelper
getAdminHelper()
BuddyListManager
getBuddyListManager()
INTERNALIDBManager
getDBManager()
Obtain a reference to the Zone's Database Manager.java.util.List<java.lang.String>
getDefaultGroups()
Get the list of Groups that each User will be automatically subscribed to when joining the Zone.java.lang.String
getDefaultPlayerIdGeneratorClassName()
java.lang.String
getDump()
ISFSExtension
getExtension()
INTERNALISystemFilterChain
getFilterChain(SystemRequest requestId)
Obtain a reference to the Zone's SystemFilterChain.IFloodFilter
getFloodFilter()
INTERNALint
getGameRoomCount()
java.util.Set<SFSRoomEvents>
getGroupEvents(java.lang.String groupId)
java.util.List<java.lang.String>
getGroups()
Get the full list of Room Groups available in the Zone.java.lang.String
getGuestUserNamePrefix()
Get the prefix used by the system to auto-generate guest user names.int
getId()
A numeric ID used by the AdminTool.int
getMaxAllowedRooms()
The maximum number of Rooms that can be created in the Room.int
getMaxAllowedUsers()
The maximum number of users allowed to join the Zone.int
getMaxFailedLogins()
The max number of login attempts (in the same session) a user can fail before being disconnected.int
getMaxFindRoomResults()
Get the max number of "FindRoom" results for a client request.int
getMaxFindUserResults()
Get the max number of "Find User" results for a client request.int
getMaxInvitationsPerRequest()
Get the max number of people that can be invited a by a single client side JoinRoomInvitationRequestint
getMaxRoomNameChars()
The maximum number of characters allowed for a Room nameint
getMaxRoomsCreatedPerUserLimit()
The maximum number of Rooms that a User can create at once.int
getMaxRoomVariablesAllowed()
The maximum number of Room Variables allowed for each Room.int
getMaxUserIdleTime()
Get the max allowed idle time for a User.int
getMaxUserVariablesAllowed()
The maximum number of User Variables allowed for each User.int
getMinRoomNameChars()
The minimum number of characters allowed for Room namejava.lang.String
getName()
The name of the Zone.PrivilegeManager
getPrivilegeManager()
java.lang.Object
getProperty(java.lang.Object key)
Properties are custom values that can be added or removed from the Zone at run-time.java.util.List<java.lang.String>
getPublicGroups()
Get a list of names of the "Public" Room Groups available in the Zone.Room
getRoomById(int id)
Get a Room from its unique IDRoom
getRoomByName(java.lang.String name)
Get a Room from its namejava.util.List<Room>
getRoomList()
Get the list of Rooms in the ZoneISFSArray
getRoomListData()
INTERNALISFSArray
getRoomListData(java.util.List<java.lang.String> groupIds)
INTERNALjava.util.List<Room>
getRoomListFromGroup(java.lang.String groupId)
Get the list of Rooms from a specific Groupjava.util.List<Room>
getRoomListFromGroupList(java.util.Collection<java.lang.String> groups)
Obtain a Room list generated by merging all Rooms from the provided group namescom.smartfoxserver.v2.entities.managers.IRoomManager
getRoomManager()
Obtain a reference to the internal Room ManagerIRoomStorage
getRoomPersistenceApi()
Obtain the Room Persistence API object.java.util.Collection<ISession>
getSessionList()
Get the list of Sessions logged in the Zonejava.util.Collection<ISession>
getSessionsInGroup(java.lang.String groupId)
Get a list of Sessions from all Rooms in the provided Room Groupjava.util.Collection<ISession>
getSessionsListeningToGroup(java.lang.String groupId)
Get a list of Sessions listening for events in a specific Groupint
getTotalRoomCount()
com.smartfoxserver.v2.util.IResponseThrottler
getUCountThrottler()
INTERNALUser
getUserById(int id)
Get a User from its unique IDUser
getUserByName(java.lang.String name)
Get a User from its nameUser
getUserBySession(ISession session)
Get a User from its Session objectint
getUserCount()
Get the current amount of Users connected to the Zoneint
getUserCountChangeUpdateInterval()
Get the rate (in ms.) at which the UserCountUpdates events are fired to the clients.java.util.Collection<User>
getUserList()
Get the list of Users logged in the Zonecom.smartfoxserver.v2.entities.managers.IUserManager
getUserManager()
int
getUserReconnectionSeconds()
Return the amount of seconds available for a User to reconnect to the system in case their socket connection goes down.java.util.Collection<User>
getUsersInGroup(java.lang.String groupId)
Get a list of Users from all Rooms in the provided Room GroupIWordFilter
getWordFilter()
INTERNALcom.smartfoxserver.v2.entities.managers.IZoneManager
getZoneManager()
void
initRoomPersistence(RoomStorageMode mode, BaseStorageConfig config)
Initializes the Room Persistence functionality.boolean
isActive()
Checks if the Zone is currently enabled in the system or not.boolean
isAllowInvitationsOnlyForBuddies()
True if only buddies can be invited by a client side JoinRoomInvitationRequest, false otherwise.boolean
isClientAllowedToOverridRoomEvents()
Deprecated.boolean
isCustomLogin()
Check if the Zone fires LOGIN events to the Zone extension at login time.boolean
isEncrypted()
True if protocol cryptography is turned on in this Zone.boolean
isFilterBuddyMessages()
Toggle the filtering of Buddy messages via the Words Filter.boolean
isFilterChainInited()
Returns true if the FilterChain was initializedboolean
isFilterPrivateMessages()
If turned on the Zone will apply the Words Filter to private messagesboolean
isFilterRoomNames()
If turned on the Zone will apply the Words Filter to Room namesboolean
isFilterUserNames()
If turned on the Zone will apply the Words Filter to User names provided at login timeboolean
isForceLogout()
If turned on it allows a User to connect from another location while another connection is already active.boolean
isGeoLocationEnabled()
Toggles geolocation for clients.boolean
isGroupEventSet(java.lang.String groupId, SFSRoomEvents eventToCheck)
Checks whether a specific Room Event for the specified Group is activeboolean
isGuestUserAllowed()
Check if the Zone allows guest users (those sending no name and no password).boolean
isHidden()
INTERNALboolean
isLagMonitorKeepAlive()
Returns true if the LagMonitor requests are also actively resetting the User's idle timerboolean
isSystemEventAllowed(java.lang.String eventID)
INTERNALboolean
isUploadEnabled()
True if the Zone supports HTTP uploads.User
login(LoginData loginData)
INTERNALvoid
registerEventsForRoomGroup(java.lang.String groupId, java.util.Set<SFSRoomEvents> flags)
void
removeAllUsers()
void
removeDisabledSystemEvent(java.lang.String eventID)
INTERNALvoid
removeProperty(java.lang.Object key)
Remove a property.void
removeRoom(int roomId)
void
removeRoom(Room room)
void
removeRoom(java.lang.String name)
void
removeUser(int userId)
INTERNALvoid
removeUser(ISession session)
INTERNALvoid
removeUser(User user)
INTERNALvoid
removeUser(java.lang.String userName)
INTERNALvoid
removeUserFromRoom(User user, Room room)
void
resetSystemFilterChain()
Resets the whole SystemController Filter chain.void
setActive(boolean flag)
Changes the state of the Zone.void
setAdminHelper(com.smartfoxserver.v2.util.IAdminHelper adminHelper)
void
setAllowInvitationsOnlyForBuddies(boolean allowInvitationsOnlyForBuddies)
Set to true if only buddies can be invited by a client side JoinRoomInvitationRequest, false otherwise.void
setBuddyListManager(BuddyListManager buddyListManager)
INTERNALvoid
setClientAllowedToOverridRoomEvents(boolean flag)
Deprecated.void
setCustomLogin(boolean flag)
Set the Zone as Custom login.void
setDBManager(IDBManager manager)
INTERNALvoid
setDefaultGroups(java.util.List<java.lang.String> groupIDs)
void
setDefaultPlayerIdGeneratorClassName(java.lang.String className)
void
setEncrypted(boolean value)
Toggles the protocol cryptography.void
setExtension(ISFSExtension extension)
INTERNALvoid
setFilterBuddyMessages(boolean flag)
If turned on the Zone will apply the Words Filter to Buddy messagesvoid
setFilterChain(SystemRequest requestId, ISystemFilterChain chain)
Set a SystemFilterChain for a specific SystemController's Request.void
setFilterPrivateMessages(boolean flag)
Toggle the filtering of private messages via the Words Filter.void
setFilterRoomNames(boolean flag)
Toggle the filtering of Room names via the Words Filter.void
setFilterUserNames(boolean flag)
Toggle the filtering of User names via the Words Filter at login time.void
setForceLogout(boolean flag)
If turned on it allows a User to connect from another location while another connection is already active.void
setGeoLocationEnabled(boolean value)
Toggles geolocation for clients.void
setGuestUserAllowed(boolean flag)
Toggles the Zone guest users (login with no name and no password).void
setGuestUserNamePrefix(java.lang.String prefix)
Set the prefix used by the system to auto-generate guest user names.void
setHidden(boolean flag)
INTERNALvoid
setId(int id)
A numeric ID used by the AdminTool.void
setLagMonitorKeepAlive(boolean value)
Resets the the Users' idle timer for every client side LagMonitor request, when set to true;void
setMaxAllowedRooms(int max)
Set the maximum number of Rooms that can be created in the Room.void
setMaxAllowedUsers(int max)
Set the maximum number of users allowed to join the Zone.void
setMaxFailedLogins(int value)
Set the max number of login attempts (in the same session) a user can fail before being disconnected.void
setMaxFindRoomResults(int value)
Set the max number of "FindRoom" results for a client request.void
setMaxFindUserResults(int value)
Set the max number of "FindUser" results for a client request.void
setMaxInvitationsPerRequest(int maxInvitationsPerRequest)
Set the max number of people that can be invited a by a single client side JoinRoomInvitationRequestvoid
setMaxRoomNameChars(int maxRoomNameChars)
Set the maximum number of characters allowed for a Room namevoid
setMaxRoomsCreatedPerUserLimit(int max)
Set the maximum number of Rooms that a User can create at once.void
setMaxRoomVariablesAllowed(int max)
Set the maximum number of Room variables allowed in the Roomvoid
setMaxUserIdleTime(int seconds)
Set the max allowed idle time for a User.void
setMaxUserVariablesAllowed(int max)
Set the maximum number of User Variables allowed for each User.void
setMinRoomNameChars(int minRoomNameChars)
Set the minimum number of characters allowed for a Room namevoid
setPrivilegeManager(PrivilegeManager privilegeManager)
void
setProperty(java.lang.Object key, java.lang.Object value)
Properties are custom values that can be added or removed from the Zone at run-time.void
setPublicGroups(java.util.List<java.lang.String> groupIDs)
void
setUploadEnabled(boolean val)
Switches on/off the ability to upload data via HTTP.void
setUserCountChangeUpdateInterval(int interval)
Set the rate (in ms.) at which the UserCountUpdates events are fired to the clients.void
setUserReconnectionSeconds(int seconds)
Set the amount of seconds available for a User to reconnect to the system in case their socket connection goes down.void
setZoneManager(com.smartfoxserver.v2.entities.managers.IZoneManager manager)
java.lang.String
toString()
void
validateUserName(java.lang.String name)
-
-
-
Method Detail
-
getRoomManager
public com.smartfoxserver.v2.entities.managers.IRoomManager getRoomManager()
Obtain a reference to the internal Room Manager- Specified by:
getRoomManager
in interfaceZone
- Returns:
- the Room Manager
-
getUserManager
public com.smartfoxserver.v2.entities.managers.IUserManager getUserManager()
- Specified by:
getUserManager
in interfaceZone
-
containsGroup
public boolean containsGroup(java.lang.String groupId)
Check if the Zone contains the specified Group- Specified by:
containsGroup
in interfaceZone
- Returns:
- true if the Zone contains the specified Group
-
containsPublicGroup
public boolean containsPublicGroup(java.lang.String groupId)
Check if the Zone contains the specified public Group- Specified by:
containsPublicGroup
in interfaceZone
- Returns:
- true if the Zone contains the specified public Group
-
createRoom
public Room createRoom(CreateRoomSettings params, User user) throws SFSCreateRoomException
Use theSFSApi.createRoom(Zone, CreateRoomSettings, User)
method instead- Specified by:
createRoom
in interfaceZone
- Throws:
SFSCreateRoomException
-
createRoom
public Room createRoom(CreateRoomSettings params) throws SFSCreateRoomException
Use theSFSApi.createRoom(Zone, CreateRoomSettings, User)
method instead- Specified by:
createRoom
in interfaceZone
- Throws:
SFSCreateRoomException
-
changeRoomName
public void changeRoomName(Room room, java.lang.String newName) throws SFSRoomException
- Specified by:
changeRoomName
in interfaceZone
- Throws:
SFSRoomException
-
changeRoomPasswordState
public void changeRoomPasswordState(Room room, java.lang.String password)
- Specified by:
changeRoomPasswordState
in interfaceZone
-
changeRoomCapacity
public void changeRoomCapacity(Room room, int newMaxUsers, int newMaxSpect)
- Specified by:
changeRoomCapacity
in interfaceZone
-
addDisabledSystemEvent
public void addDisabledSystemEvent(java.lang.String eventID)
Description copied from interface:Zone
INTERNAL- Specified by:
addDisabledSystemEvent
in interfaceZone
-
addRoom
public void addRoom(Room room) throws SFSTooManyRoomsException
Description copied from interface:Zone
INTERNALInstead use
SFSApi.createRoom(Zone, CreateRoomSettings, User)
- Specified by:
addRoom
in interfaceZone
- Throws:
SFSTooManyRoomsException
-
getGuestUserNamePrefix
public java.lang.String getGuestUserNamePrefix()
Get the prefix used by the system to auto-generate guest user names.Example: by default the prefix is "Guest#"
At the end of the prefix it will be added the unique user id.- Specified by:
getGuestUserNamePrefix
in interfaceZone
- Returns:
- the user name prefix
-
getUserCount
public int getUserCount()
Get the current amount of Users connected to the Zone- Specified by:
getUserCount
in interfaceZone
- Returns:
- the amount of Users connected to the Zone
-
getTotalRoomCount
public int getTotalRoomCount()
- Specified by:
getTotalRoomCount
in interfaceZone
-
getGameRoomCount
public int getGameRoomCount()
- Specified by:
getGameRoomCount
in interfaceZone
-
getMaxAllowedRooms
public int getMaxAllowedRooms()
The maximum number of Rooms that can be created in the Room.- Specified by:
getMaxAllowedRooms
in interfaceZone
- Returns:
- the maximum number of Rooms that can be created in the Room.
-
getMaxUserVariablesAllowed
public int getMaxUserVariablesAllowed()
The maximum number of User Variables allowed for each User.- Specified by:
getMaxUserVariablesAllowed
in interfaceZone
- Returns:
- the maximum number of User Variables allowed for each User.
-
getMaxAllowedUsers
public int getMaxAllowedUsers()
The maximum number of users allowed to join the Zone.- Specified by:
getMaxAllowedUsers
in interfaceZone
- Returns:
- the maximum number of users allowed to join the Zone.
-
getMaxRoomsCreatedPerUserLimit
public int getMaxRoomsCreatedPerUserLimit()
The maximum number of Rooms that a User can create at once.Example: if the limit is == 3 and the User has created Rooms A, B and C he won't be able to create any more Room at least until any of these Rooms is destroyed.
- Specified by:
getMaxRoomsCreatedPerUserLimit
in interfaceZone
- Returns:
- the maximum number of Rooms that a User can create at once.
-
getName
public java.lang.String getName()
The name of the Zone. Each Zone must have a unique name.
-
getId
public int getId()
A numeric ID used by the AdminTool. The true identifier of a Zone is its name
-
getProperty
public java.lang.Object getProperty(java.lang.Object key)
Properties are custom values that can be added or removed from the Zone at run-time. They can be used for many purposes, in particular to keep global references that can be shared across multiple objects in the extension code, Rooms etc...- Specified by:
getProperty
in interfaceZone
- Parameters:
key
- the name of the property- Returns:
- the value of the property, null if the property doesn't exist
-
removeProperty
public void removeProperty(java.lang.Object key)
Remove a property.- Specified by:
removeProperty
in interfaceZone
- Parameters:
key
- the name of the property.- See Also:
Zone.setProperty(Object, Object)
-
getPublicGroups
public java.util.List<java.lang.String> getPublicGroups()
Get a list of names of the "Public" Room Groups available in the Zone. Public Groups are those in which the client is allowed to create Rooms dynamically. The other Groups can be manipulated only via server side code.- Specified by:
getPublicGroups
in interfaceZone
- Returns:
- the list of group ids
-
getGroups
public java.util.List<java.lang.String> getGroups()
Get the full list of Room Groups available in the Zone. More groups can be added from server side by simply assigning a non-existent Group Id to a newly created Room. As soon as the new Group is detected, it will be added to the Group List
-
getDefaultGroups
public java.util.List<java.lang.String> getDefaultGroups()
Get the list of Groups that each User will be automatically subscribed to when joining the Zone.- Specified by:
getDefaultGroups
in interfaceZone
- Returns:
- the list of default groups
- See Also:
SFSApi.subscribeRoomGroup(User, String)
-
getRoomById
public Room getRoomById(int id)
Get a Room from its unique ID- Specified by:
getRoomById
in interfaceZone
- Parameters:
id
- the Room id- Returns:
- the Room or null if no Room exists with the specified ID
-
getRoomByName
public Room getRoomByName(java.lang.String name)
Get a Room from its name- Specified by:
getRoomByName
in interfaceZone
- Parameters:
name
- the Room name- Returns:
- the Room or null if no Room exists with the specified name
-
getRoomList
public java.util.List<Room> getRoomList()
Get the list of Rooms in the Zone- Specified by:
getRoomList
in interfaceZone
- Returns:
- the room list
-
getRoomListFromGroup
public java.util.List<Room> getRoomListFromGroup(java.lang.String groupId)
Get the list of Rooms from a specific Group- Specified by:
getRoomListFromGroup
in interfaceZone
- Parameters:
groupId
- the id of the group- Returns:
- the list of Rooms in the specified Group
-
getRoomListFromGroupList
public java.util.List<Room> getRoomListFromGroupList(java.util.Collection<java.lang.String> groups)
Description copied from interface:Zone
Obtain a Room list generated by merging all Rooms from the provided group names- Specified by:
getRoomListFromGroupList
in interfaceZone
- Parameters:
groups
- a list of valid Room Group names- Returns:
- the Room list generated by merging all Rooms from the provided group names
-
getUserById
public User getUserById(int id)
Get a User from its unique ID- Specified by:
getUserById
in interfaceZone
- Parameters:
id
- the User ID- Returns:
- the User, or null if no User exists with the provided ID
-
getUserByName
public User getUserByName(java.lang.String name)
Get a User from its name- Specified by:
getUserByName
in interfaceZone
- Parameters:
name
- the User name- Returns:
- the User, or null if no User exists with the provided name
-
getUserBySession
public User getUserBySession(ISession session)
Get a User from its Session object- Specified by:
getUserBySession
in interfaceZone
- Parameters:
session
- the Session- Returns:
- the User, or null if no User exists for the provided Session. In this case it would mean that the client is connected but not logged id.
-
getUserCountChangeUpdateInterval
public int getUserCountChangeUpdateInterval()
Get the rate (in ms.) at which the UserCountUpdates events are fired to the clients.A value of zero will use the default, real-time updating that was also present in SmartFoxServer 1.x In high traffic servers these updates could be thousands per second, so we highly recommend to use a slower update rate in order to optimize the network usage. Reasonable values can be in the range of 500ms - 2000ms
- Specified by:
getUserCountChangeUpdateInterval
in interfaceZone
- Returns:
- the interval in milliseconds between each UserCountUpdate
-
getUCountThrottler
public com.smartfoxserver.v2.util.IResponseThrottler getUCountThrottler()
Description copied from interface:Zone
INTERNAL- Specified by:
getUCountThrottler
in interfaceZone
-
getDefaultPlayerIdGeneratorClassName
public java.lang.String getDefaultPlayerIdGeneratorClassName()
- Specified by:
getDefaultPlayerIdGeneratorClassName
in interfaceZone
-
setDefaultPlayerIdGeneratorClassName
public void setDefaultPlayerIdGeneratorClassName(java.lang.String className)
- Specified by:
setDefaultPlayerIdGeneratorClassName
in interfaceZone
-
isUploadEnabled
public boolean isUploadEnabled()
True if the Zone supports HTTP uploads.- Specified by:
isUploadEnabled
in interfaceZone
- Returns:
- true if the Zone supports HTTP uploads.
-
setUploadEnabled
public void setUploadEnabled(boolean val)
Switches on/off the ability to upload data via HTTP. This in turn causes theSFSEventType.FILE_UPLOAD
event to be fired at Zone Level.- Specified by:
setUploadEnabled
in interfaceZone
-
isLagMonitorKeepAlive
public boolean isLagMonitorKeepAlive()
Description copied from interface:Zone
Returns true if the LagMonitor requests are also actively resetting the User's idle timer- Specified by:
isLagMonitorKeepAlive
in interfaceZone
-
setLagMonitorKeepAlive
public void setLagMonitorKeepAlive(boolean value)
Description copied from interface:Zone
Resets the the Users' idle timer for every client side LagMonitor request, when set to true;- Specified by:
setLagMonitorKeepAlive
in interfaceZone
- Parameters:
value
- whether or not the LagMonitor requests should reset the User's idle timer
-
isFilterChainInited
public boolean isFilterChainInited()
Returns true if the FilterChain was initialized- Specified by:
isFilterChainInited
in interfaceZone
- Returns:
- true if at least one Filter was added to the FilterChain
-
resetSystemFilterChain
public void resetSystemFilterChain()
Resets the whole SystemController Filter chain. All filters for any SystemRequest is removed.- Specified by:
resetSystemFilterChain
in interfaceZone
-
isHidden
public boolean isHidden()
Description copied from interface:Zone
INTERNAL
-
setHidden
public void setHidden(boolean flag)
Description copied from interface:Zone
INTERNAL
-
getFilterChain
public ISystemFilterChain getFilterChain(SystemRequest requestId)
Obtain a reference to the Zone's SystemFilterChain. Here you can add custom filters that will execute before any System Request is handled by the system itself.- Specified by:
getFilterChain
in interfaceZone
- Parameters:
requestId
- the request id associated with the filter chain- Returns:
- the SystemFilterChain
- See Also:
ISystemFilterChain
,ISystemFilter
-
setFilterChain
public void setFilterChain(SystemRequest requestId, ISystemFilterChain chain)
Set a SystemFilterChain for a specific SystemController's Request. For example you can set one ore more filters for the CreateRoom request or the PublicMessage etc... The filter chain will be executed before the request is passed to the SystemController.- Specified by:
setFilterChain
in interfaceZone
- Parameters:
requestId
- the SystemController request Idchain
- the filter chain- See Also:
SysControllerFilterChain
,SysControllerFilter
-
getExtension
public ISFSExtension getExtension()
INTERNAL- Specified by:
getExtension
in interfaceZone
-
setExtension
public void setExtension(ISFSExtension extension)
Description copied from interface:Zone
INTERNAL- Specified by:
setExtension
in interfaceZone
-
getUserReconnectionSeconds
public int getUserReconnectionSeconds()
Return the amount of seconds available for a User to reconnect to the system in case their socket connection goes down. A value of zero will turn the reconnection feature off.- Specified by:
getUserReconnectionSeconds
in interfaceZone
- Returns:
- the amount of seconds to reconnect.
-
setUserReconnectionSeconds
public void setUserReconnectionSeconds(int seconds)
Set the amount of seconds available for a User to reconnect to the system in case their socket connection goes down. A value of zero will turn the reconnection feature off.- Specified by:
setUserReconnectionSeconds
in interfaceZone
- Parameters:
seconds
- the amount of seconds to reconnect
-
getMaxUserIdleTime
public int getMaxUserIdleTime()
Get the max allowed idle time for a User. When this interval expires the server will disconnect the "idle" User. Any request sent from the client will reset the Idle timer.- Specified by:
getMaxUserIdleTime
in interfaceZone
- Returns:
- the time in seconds
-
setMaxUserIdleTime
public void setMaxUserIdleTime(int seconds)
Set the max allowed idle time for a User. When this interval expires the server will disconnect the "idle" User. Any request sent from the client will reset the Idle timer.- Specified by:
setMaxUserIdleTime
in interfaceZone
- Parameters:
seconds
- the interval
-
getUsersInGroup
public java.util.Collection<User> getUsersInGroup(java.lang.String groupId)
Get a list of Users from all Rooms in the provided Room Group- Specified by:
getUsersInGroup
in interfaceZone
- Parameters:
groupId
- a group Id- Returns:
- the list of Users from all Rooms in the provided Room Group
-
getSessionsInGroup
public java.util.Collection<ISession> getSessionsInGroup(java.lang.String groupId)
Get a list of Sessions from all Rooms in the provided Room Group- Specified by:
getSessionsInGroup
in interfaceZone
- Parameters:
groupId
- a group Id- Returns:
- the list of Sessions from all Rooms in the provided Room Group
-
getSessionsListeningToGroup
public java.util.Collection<ISession> getSessionsListeningToGroup(java.lang.String groupId)
Description copied from interface:Zone
Get a list of Sessions listening for events in a specific Group- Specified by:
getSessionsListeningToGroup
in interfaceZone
- Parameters:
groupId
- a group Id- Returns:
- the list of Sessions listening for events in a specific Group
-
getSessionList
public java.util.Collection<ISession> getSessionList()
Get the list of Sessions logged in the Zone- Specified by:
getSessionList
in interfaceZone
- Returns:
- the list of Sessions logged in the Zone
-
getUserList
public java.util.Collection<User> getUserList()
Get the list of Users logged in the Zone- Specified by:
getUserList
in interfaceZone
- Returns:
- the list of Users logged in the Zone
-
getZoneManager
public com.smartfoxserver.v2.entities.managers.IZoneManager getZoneManager()
- Specified by:
getZoneManager
in interfaceZone
-
isActive
public boolean isActive()
Checks if the Zone is currently enabled in the system or not. Inactive Zones won't allow anyone to login. You can deactivate a Zone at runtime (from the AdminTool) if you are planning to remove it. All Users will be disconnected.
-
isClientAllowedToOverridRoomEvents
public boolean isClientAllowedToOverridRoomEvents()
Deprecated.- Specified by:
isClientAllowedToOverridRoomEvents
in interfaceZone
-
isCustomLogin
public boolean isCustomLogin()
Check if the Zone fires LOGIN events to the Zone extension at login time. This allows the developer to take full control over the login process in their extension code, like checking the credentials etc...- Specified by:
isCustomLogin
in interfaceZone
- Returns:
- true if the Zone uses a custom login process
- See Also:
SFSEvent
,SFSEventType
-
isForceLogout
public boolean isForceLogout()
If turned on it allows a User to connect from another location while another connection is already active. This will result in the first session to be disconnected and the new one to be started.- Specified by:
isForceLogout
in interfaceZone
- Returns:
- true if the feature is turned on
-
isGuestUserAllowed
public boolean isGuestUserAllowed()
Check if the Zone allows guest users (those sending no name and no password). If so the server will automatically set up a "guest name" for the User.- Specified by:
isGuestUserAllowed
in interfaceZone
- Returns:
- true if the Zone allows guests
- See Also:
Zone.getGuestUserNamePrefix()
-
isSystemEventAllowed
public boolean isSystemEventAllowed(java.lang.String eventID)
INTERNAL- Specified by:
isSystemEventAllowed
in interfaceZone
-
isFilterUserNames
public boolean isFilterUserNames()
If turned on the Zone will apply the Words Filter to User names provided at login time- Specified by:
isFilterUserNames
in interfaceZone
- Returns:
- true if filtering is turned on
-
isFilterRoomNames
public boolean isFilterRoomNames()
If turned on the Zone will apply the Words Filter to Room names- Specified by:
isFilterRoomNames
in interfaceZone
- Returns:
- true if filtering is turned on
-
setFilterRoomNames
public void setFilterRoomNames(boolean flag)
Toggle the filtering of Room names via the Words Filter.- Specified by:
setFilterRoomNames
in interfaceZone
- Parameters:
flag
- a boolean
-
isFilterBuddyMessages
public boolean isFilterBuddyMessages()
Toggle the filtering of Buddy messages via the Words Filter.- Specified by:
isFilterBuddyMessages
in interfaceZone
- Returns:
- true if buddy messages filtering is turned on
-
setFilterBuddyMessages
public void setFilterBuddyMessages(boolean flag)
If turned on the Zone will apply the Words Filter to Buddy messages- Specified by:
setFilterBuddyMessages
in interfaceZone
-
containsProperty
public boolean containsProperty(java.lang.Object key)
Checks the existance of a Zone property- Specified by:
containsProperty
in interfaceZone
- Parameters:
key
- the name of the property- Returns:
- true if the property exists
-
registerEventsForRoomGroup
public void registerEventsForRoomGroup(java.lang.String groupId, java.util.Set<SFSRoomEvents> flags)
- Specified by:
registerEventsForRoomGroup
in interfaceZone
-
isGroupEventSet
public boolean isGroupEventSet(java.lang.String groupId, SFSRoomEvents eventToCheck)
Checks whether a specific Room Event for the specified Group is active- Specified by:
isGroupEventSet
in interfaceZone
- Parameters:
groupId
- the group nameeventToCheck
- the type of event to check- Returns:
- true if the event is active
-
getGroupEvents
public java.util.Set<SFSRoomEvents> getGroupEvents(java.lang.String groupId)
- Specified by:
getGroupEvents
in interfaceZone
-
removeDisabledSystemEvent
public void removeDisabledSystemEvent(java.lang.String eventID)
Description copied from interface:Zone
INTERNAL- Specified by:
removeDisabledSystemEvent
in interfaceZone
-
removeRoom
public void removeRoom(int roomId)
- Specified by:
removeRoom
in interfaceZone
-
removeRoom
public void removeRoom(java.lang.String name)
- Specified by:
removeRoom
in interfaceZone
-
removeRoom
public void removeRoom(Room room)
- Specified by:
removeRoom
in interfaceZone
-
checkAndRemove
public void checkAndRemove(Room room)
- Specified by:
checkAndRemove
in interfaceZone
-
removeUserFromRoom
public void removeUserFromRoom(User user, Room room)
- Specified by:
removeUserFromRoom
in interfaceZone
-
getMinRoomNameChars
public int getMinRoomNameChars()
The minimum number of characters allowed for Room name- Specified by:
getMinRoomNameChars
in interfaceZone
- Returns:
- the minimum number of characters allowed for Room name
-
setMinRoomNameChars
public void setMinRoomNameChars(int minRoomNameChars)
Set the minimum number of characters allowed for a Room name- Specified by:
setMinRoomNameChars
in interfaceZone
- Parameters:
minRoomNameChars
- the minimum number of characters allowed for Room name
-
getMaxRoomNameChars
public int getMaxRoomNameChars()
The maximum number of characters allowed for a Room name- Specified by:
getMaxRoomNameChars
in interfaceZone
- Returns:
- the maximum number of characters allowed for a Room name
-
setMaxRoomNameChars
public void setMaxRoomNameChars(int maxRoomNameChars)
Set the maximum number of characters allowed for a Room name- Specified by:
setMaxRoomNameChars
in interfaceZone
- Parameters:
maxRoomNameChars
- the maximum number of characters allowed for a Room name
-
setActive
public void setActive(boolean flag)
Changes the state of the Zone. De-activating a Zone at runtime will result in an abrupt disconnection of all Users. Use only when strictly necessary.
-
setId
public void setId(int id)
Description copied from interface:Zone
A numeric ID used by the AdminTool. The true identifier of a Zone is its name
-
setClientAllowedToOverridRoomEvents
public void setClientAllowedToOverridRoomEvents(boolean flag)
Deprecated.- Specified by:
setClientAllowedToOverridRoomEvents
in interfaceZone
-
setCustomLogin
public void setCustomLogin(boolean flag)
Description copied from interface:Zone
Set the Zone as Custom login. If turned on the developer's Extension will be able to take control over the login process.- Specified by:
setCustomLogin
in interfaceZone
- See Also:
SFSEvent
,SFSEventType
-
setForceLogout
public void setForceLogout(boolean flag)
Description copied from interface:Zone
If turned on it allows a User to connect from another location while another connection is already active. This will result in the first session to be disconnected and the new one to be started.- Specified by:
setForceLogout
in interfaceZone
-
setGuestUserAllowed
public void setGuestUserAllowed(boolean flag)
Toggles the Zone guest users (login with no name and no password). If active the server will automatically set up a "guest name" for the User.- Specified by:
setGuestUserAllowed
in interfaceZone
- See Also:
Zone.getGuestUserNamePrefix()
-
setFilterUserNames
public void setFilterUserNames(boolean flag)
Toggle the filtering of User names via the Words Filter at login time.- Specified by:
setFilterUserNames
in interfaceZone
-
setGuestUserNamePrefix
public void setGuestUserNamePrefix(java.lang.String prefix)
Set the prefix used by the system to auto-generate guest user names.Example: by default the prefix is "Guest#"
At the end of the prefix it will be added the unique user id.- Specified by:
setGuestUserNamePrefix
in interfaceZone
-
setMaxAllowedRooms
public void setMaxAllowedRooms(int max)
Set the maximum number of Rooms that can be created in the Room.- Specified by:
setMaxAllowedRooms
in interfaceZone
- Parameters:
max
- the maximum number of Rooms that can be created in the Room.
-
setMaxAllowedUsers
public void setMaxAllowedUsers(int max)
Set the maximum number of users allowed to join the Zone.- Specified by:
setMaxAllowedUsers
in interfaceZone
- Parameters:
max
- the max allowed Users
-
setMaxUserVariablesAllowed
public void setMaxUserVariablesAllowed(int max)
Set the maximum number of User Variables allowed for each User.- Specified by:
setMaxUserVariablesAllowed
in interfaceZone
- Parameters:
max
- the maximum number of User Variables allowed for each User.
-
setMaxRoomsCreatedPerUserLimit
public void setMaxRoomsCreatedPerUserLimit(int max)
Set the maximum number of Rooms that a User can create at once.- Specified by:
setMaxRoomsCreatedPerUserLimit
in interfaceZone
- Parameters:
max
- the maximum number of Rooms that a User can create at once.
-
setProperty
public void setProperty(java.lang.Object key, java.lang.Object value)
Properties are custom values that can be added or removed from the Zone at run-time. They can be used for many purposes, in particular to keep global references that can be shared across multiple objects in the extension code, Rooms etc...- Specified by:
setProperty
in interfaceZone
- Parameters:
key
- the name of the propertyvalue
- the value of the property
-
setPublicGroups
public void setPublicGroups(java.util.List<java.lang.String> groupIDs)
- Specified by:
setPublicGroups
in interfaceZone
-
setDefaultGroups
public void setDefaultGroups(java.util.List<java.lang.String> groupIDs)
- Specified by:
setDefaultGroups
in interfaceZone
-
setUserCountChangeUpdateInterval
public void setUserCountChangeUpdateInterval(int interval)
Set the rate (in ms.) at which the UserCountUpdates events are fired to the clients.- Specified by:
setUserCountChangeUpdateInterval
in interfaceZone
- Parameters:
interval
- the interval in ms between each UserCountUpdate. Recommended range: 500-2000ms.
-
setZoneManager
public void setZoneManager(com.smartfoxserver.v2.entities.managers.IZoneManager manager)
- Specified by:
setZoneManager
in interfaceZone
-
validateUserName
public void validateUserName(java.lang.String name) throws SFSException
- Specified by:
validateUserName
in interfaceZone
- Throws:
SFSException
-
getFloodFilter
public IFloodFilter getFloodFilter()
INTERNAL- Specified by:
getFloodFilter
in interfaceZone
-
getWordFilter
public IWordFilter getWordFilter()
INTERNAL- Specified by:
getWordFilter
in interfaceZone
-
removeAllUsers
public void removeAllUsers()
- Specified by:
removeAllUsers
in interfaceZone
-
removeUser
public void removeUser(int userId)
INTERNALInstead use
SFSApi.disconnectUser(User)
- Specified by:
removeUser
in interfaceZone
-
removeUser
public void removeUser(ISession session)
INTERNALInstead use
SFSApi.disconnect(ISession)
- Specified by:
removeUser
in interfaceZone
-
removeUser
public void removeUser(java.lang.String userName)
INTERNALInstead use
SFSApi.disconnectUser(User)
- Specified by:
removeUser
in interfaceZone
-
removeUser
public void removeUser(User user)
INTERNALInstead use
SFSApi.disconnectUser(User)
- Specified by:
removeUser
in interfaceZone
-
getMaxRoomVariablesAllowed
public int getMaxRoomVariablesAllowed()
The maximum number of Room Variables allowed for each Room.NOTE: each Room can set its own limit of Room Variables. However when a Room is created from a client request this Zone limit is applied.
- Specified by:
getMaxRoomVariablesAllowed
in interfaceZone
- Returns:
- the maximum number of Room Variables allowed for each Room.
-
setMaxRoomVariablesAllowed
public void setMaxRoomVariablesAllowed(int max)
Set the maximum number of Room variables allowed in the Room- Specified by:
setMaxRoomVariablesAllowed
in interfaceZone
- Parameters:
max
- the maximum number of Room variables allowed in the RoomNOTE: each Room can set its own limit of Room Variables. However when a Room is created from a client request this Zone limit is applied.
-
getPrivilegeManager
public PrivilegeManager getPrivilegeManager()
- Specified by:
getPrivilegeManager
in interfaceZone
-
setPrivilegeManager
public void setPrivilegeManager(PrivilegeManager privilegeManager)
- Specified by:
setPrivilegeManager
in interfaceZone
-
getBuddyListManager
public BuddyListManager getBuddyListManager()
INTERNALInstead use
SFSBuddyApi
- Specified by:
getBuddyListManager
in interfaceZone
-
setBuddyListManager
public void setBuddyListManager(BuddyListManager buddyListManager)
INTERNAL- Specified by:
setBuddyListManager
in interfaceZone
-
getDBManager
public IDBManager getDBManager()
Obtain a reference to the Zone's Database Manager.- Specified by:
getDBManager
in interfaceZone
- See Also:
SFSDBManager
-
setDBManager
public void setDBManager(IDBManager manager)
Description copied from interface:Zone
INTERNAL- Specified by:
setDBManager
in interfaceZone
-
isFilterPrivateMessages
public boolean isFilterPrivateMessages()
If turned on the Zone will apply the Words Filter to private messages- Specified by:
isFilterPrivateMessages
in interfaceZone
- Returns:
- true if the Words Filter is applied to private messages
-
setFilterPrivateMessages
public void setFilterPrivateMessages(boolean flag)
Toggle the filtering of private messages via the Words Filter.- Specified by:
setFilterPrivateMessages
in interfaceZone
-
login
public User login(LoginData loginData) throws SFSLoginException
INTERNALInstead use
SFSApi.login(ISession, String, String, String, com.smartfoxserver.v2.entities.data.ISFSObject)
- Specified by:
login
in interfaceZone
- Throws:
SFSLoginException
-
getRoomListData
public ISFSArray getRoomListData()
Description copied from interface:Zone
INTERNAL- Specified by:
getRoomListData
in interfaceZone
-
getRoomListData
public ISFSArray getRoomListData(java.util.List<java.lang.String> groupIds)
Description copied from interface:Zone
INTERNAL- Specified by:
getRoomListData
in interfaceZone
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getAdminHelper
public com.smartfoxserver.v2.util.IAdminHelper getAdminHelper()
-
setAdminHelper
public void setAdminHelper(com.smartfoxserver.v2.util.IAdminHelper adminHelper)
-
initRoomPersistence
public void initRoomPersistence(RoomStorageMode mode, BaseStorageConfig config)
Initializes the Room Persistence functionality. Typically you will invoke this method in the init() method of your Extension.The Room Persistence API provides two different storage systems for Rooms:
- FILE_STORAGE: which uses the local file system to store Room data. Doesn't require a config object.
- DB_STORAGE which uses an external database (via the Zone's DBManager) to store Room data. Requires a config object.
- Specified by:
initRoomPersistence
in interfaceZone
config
- an optional config object. At the moment it is required only for DB_STORAGE mode only.- See Also:
RoomStorageMode
,SFSDBManager
,IRoomStorage
-
getRoomPersistenceApi
public IRoomStorage getRoomPersistenceApi()
Obtain the Room Persistence API object.IMPORTANT: it is necessary to first initialize the Persistence system before accessing it. Failing this will return a null object.
- Specified by:
getRoomPersistenceApi
in interfaceZone
- Returns:
- the Room Persistence API object or null if the API was not initialized.
- See Also:
Zone.initRoomPersistence(RoomStorageMode, BaseStorageConfig)
,IRoomStorage
-
isEncrypted
public boolean isEncrypted()
True if protocol cryptography is turned on in this Zone. Requests sent unencrypted when the flag is turned ON will result in a sudden client disconnection.- Specified by:
isEncrypted
in interfaceZone
- Returns:
- returns true if protocol cryptography is turned on in this Zone
-
setEncrypted
public void setEncrypted(boolean value)
Toggles the protocol cryptography.- Specified by:
setEncrypted
in interfaceZone
- Parameters:
value
- toggles protocol cryptography.
-
getMaxInvitationsPerRequest
public int getMaxInvitationsPerRequest()
Get the max number of people that can be invited a by a single client side JoinRoomInvitationRequest- Specified by:
getMaxInvitationsPerRequest
in interfaceZone
- Returns:
- the max number of people that can be invited a by a single client side JoinRoomInvitationRequest
-
setMaxInvitationsPerRequest
public void setMaxInvitationsPerRequest(int maxInvitationsPerRequest)
Set the max number of people that can be invited a by a single client side JoinRoomInvitationRequest- Specified by:
setMaxInvitationsPerRequest
in interfaceZone
- Parameters:
maxInvitationsPerRequest
- the max number of people that can be invited in each request
-
isAllowInvitationsOnlyForBuddies
public boolean isAllowInvitationsOnlyForBuddies()
True if only buddies can be invited by a client side JoinRoomInvitationRequest, false otherwise.- Specified by:
isAllowInvitationsOnlyForBuddies
in interfaceZone
- Returns:
- True if only buddies can be invited by a client side JoinRoomInvitationRequest, false otherwise.
-
setAllowInvitationsOnlyForBuddies
public void setAllowInvitationsOnlyForBuddies(boolean allowInvitationsOnlyForBuddies)
Set to true if only buddies can be invited by a client side JoinRoomInvitationRequest, false otherwise.- Specified by:
setAllowInvitationsOnlyForBuddies
in interfaceZone
-
getMaxFailedLogins
public int getMaxFailedLogins()
Description copied from interface:Zone
The max number of login attempts (in the same session) a user can fail before being disconnected.- Specified by:
getMaxFailedLogins
in interfaceZone
- Returns:
- the max number of login attempts (in the same session) a user can fail before being disconnected.
-
setMaxFailedLogins
public void setMaxFailedLogins(int value)
Description copied from interface:Zone
Set the max number of login attempts (in the same session) a user can fail before being disconnected.- Specified by:
setMaxFailedLogins
in interfaceZone
- Parameters:
value
- the max number of login attempts (in the same session) a user can fail before being disconnected.
-
isGeoLocationEnabled
public boolean isGeoLocationEnabled()
Description copied from interface:Zone
Toggles geolocation for clients.- Specified by:
isGeoLocationEnabled
in interfaceZone
- Returns:
- true if geolocation is enabled in this Zone
-
setGeoLocationEnabled
public void setGeoLocationEnabled(boolean value)
Description copied from interface:Zone
Toggles geolocation for clients.NOTE:IP address geolocation is done via a local database so the added performance cost is negligible.
- Specified by:
setGeoLocationEnabled
in interfaceZone
- Parameters:
value
- true to enable the geolocation service, false to turn it off. Default = false
-
getMaxFindUserResults
public int getMaxFindUserResults()
Description copied from interface:Zone
Get the max number of "Find User" results for a client request. Default is 50.- Specified by:
getMaxFindUserResults
in interfaceZone
-
setMaxFindUserResults
public void setMaxFindUserResults(int value)
Description copied from interface:Zone
Set the max number of "FindUser" results for a client request. Default is 50.- Specified by:
setMaxFindUserResults
in interfaceZone
-
getMaxFindRoomResults
public int getMaxFindRoomResults()
Description copied from interface:Zone
Get the max number of "FindRoom" results for a client request. Default is 50.- Specified by:
getMaxFindRoomResults
in interfaceZone
-
setMaxFindRoomResults
public void setMaxFindRoomResults(int value)
Description copied from interface:Zone
Set the max number of "FindRoom" results for a client request. Default is 50.- Specified by:
setMaxFindRoomResults
in interfaceZone
-
-