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 booleanlagMonitorKeepAlive
-
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 voidaddDisabledSystemEvent(java.lang.String eventID)INTERNALvoidaddRoom(Room room)INTERNALvoidchangeRoomCapacity(Room room, int newMaxUsers, int newMaxSpect)voidchangeRoomName(Room room, java.lang.String newName)voidchangeRoomPasswordState(Room room, java.lang.String password)voidcheckAndRemove(Room room)booleancontainsGroup(java.lang.String groupId)Check if the Zone contains the specified GroupbooleancontainsProperty(java.lang.Object key)Checks the existance of a Zone propertybooleancontainsPublicGroup(java.lang.String groupId)Check if the Zone contains the specified public GroupRoomcreateRoom(CreateRoomSettings params)Use theSFSApi.createRoom(Zone, CreateRoomSettings, User)method insteadRoomcreateRoom(CreateRoomSettings params, User user)Use theSFSApi.createRoom(Zone, CreateRoomSettings, User)method insteadcom.smartfoxserver.v2.util.IAdminHelpergetAdminHelper()BuddyListManagergetBuddyListManager()INTERNALIDBManagergetDBManager()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.StringgetDefaultPlayerIdGeneratorClassName()java.lang.StringgetDump()ISFSExtensiongetExtension()INTERNALISystemFilterChaingetFilterChain(SystemRequest requestId)Obtain a reference to the Zone's SystemFilterChain.IFloodFiltergetFloodFilter()INTERNALintgetGameRoomCount()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.StringgetGuestUserNamePrefix()Get the prefix used by the system to auto-generate guest user names.intgetId()A numeric ID used by the AdminTool.intgetMaxAllowedRooms()The maximum number of Rooms that can be created in the Room.intgetMaxAllowedUsers()The maximum number of users allowed to join the Zone.intgetMaxFailedLogins()The max number of login attempts (in the same session) a user can fail before being disconnected.intgetMaxFindRoomResults()Get the max number of "FindRoom" results for a client request.intgetMaxFindUserResults()Get the max number of "Find User" results for a client request.intgetMaxInvitationsPerRequest()Get the max number of people that can be invited a by a single client side JoinRoomInvitationRequestintgetMaxRoomNameChars()The maximum number of characters allowed for a Room nameintgetMaxRoomsCreatedPerUserLimit()The maximum number of Rooms that a User can create at once.intgetMaxRoomVariablesAllowed()The maximum number of Room Variables allowed for each Room.intgetMaxUserIdleTime()Get the max allowed idle time for a User.intgetMaxUserVariablesAllowed()The maximum number of User Variables allowed for each User.intgetMinRoomNameChars()The minimum number of characters allowed for Room namejava.lang.StringgetName()The name of the Zone.PrivilegeManagergetPrivilegeManager()java.lang.ObjectgetProperty(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.RoomgetRoomById(int id)Get a Room from its unique IDRoomgetRoomByName(java.lang.String name)Get a Room from its namejava.util.List<Room>getRoomList()Get the list of Rooms in the ZoneISFSArraygetRoomListData()INTERNALISFSArraygetRoomListData(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.IRoomManagergetRoomManager()Obtain a reference to the internal Room ManagerIRoomStoragegetRoomPersistenceApi()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 GroupintgetTotalRoomCount()com.smartfoxserver.v2.util.IResponseThrottlergetUCountThrottler()INTERNALUsergetUserById(int id)Get a User from its unique IDUsergetUserByName(java.lang.String name)Get a User from its nameUsergetUserBySession(ISession session)Get a User from its Session objectintgetUserCount()Get the current amount of Users connected to the ZoneintgetUserCountChangeUpdateInterval()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.IUserManagergetUserManager()intgetUserReconnectionSeconds()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 GroupIWordFiltergetWordFilter()INTERNALcom.smartfoxserver.v2.entities.managers.IZoneManagergetZoneManager()voidinitRoomPersistence(RoomStorageMode mode, BaseStorageConfig config)Initializes the Room Persistence functionality.booleanisActive()Checks if the Zone is currently enabled in the system or not.booleanisAllowInvitationsOnlyForBuddies()True if only buddies can be invited by a client side JoinRoomInvitationRequest, false otherwise.booleanisClientAllowedToOverridRoomEvents()Deprecated.booleanisCustomLogin()Check if the Zone fires LOGIN events to the Zone extension at login time.booleanisEncrypted()True if protocol cryptography is turned on in this Zone.booleanisFilterBuddyMessages()Toggle the filtering of Buddy messages via the Words Filter.booleanisFilterChainInited()Returns true if the FilterChain was initializedbooleanisFilterPrivateMessages()If turned on the Zone will apply the Words Filter to private messagesbooleanisFilterRoomNames()If turned on the Zone will apply the Words Filter to Room namesbooleanisFilterUserNames()If turned on the Zone will apply the Words Filter to User names provided at login timebooleanisForceLogout()If turned on it allows a User to connect from another location while another connection is already active.booleanisGeoLocationEnabled()Toggles geolocation for clients.booleanisGroupEventSet(java.lang.String groupId, SFSRoomEvents eventToCheck)Checks whether a specific Room Event for the specified Group is activebooleanisGuestUserAllowed()Check if the Zone allows guest users (those sending no name and no password).booleanisHidden()INTERNALbooleanisLagMonitorKeepAlive()Returns true if the LagMonitor requests are also actively resetting the User's idle timerbooleanisSystemEventAllowed(java.lang.String eventID)INTERNALbooleanisUploadEnabled()True if the Zone supports HTTP uploads.Userlogin(LoginData loginData)INTERNALvoidregisterEventsForRoomGroup(java.lang.String groupId, java.util.Set<SFSRoomEvents> flags)voidremoveAllUsers()voidremoveDisabledSystemEvent(java.lang.String eventID)INTERNALvoidremoveProperty(java.lang.Object key)Remove a property.voidremoveRoom(int roomId)voidremoveRoom(Room room)voidremoveRoom(java.lang.String name)voidremoveUser(int userId)INTERNALvoidremoveUser(ISession session)INTERNALvoidremoveUser(User user)INTERNALvoidremoveUser(java.lang.String userName)INTERNALvoidremoveUserFromRoom(User user, Room room)voidresetSystemFilterChain()Resets the whole SystemController Filter chain.voidsetActive(boolean flag)Changes the state of the Zone.voidsetAdminHelper(com.smartfoxserver.v2.util.IAdminHelper adminHelper)voidsetAllowInvitationsOnlyForBuddies(boolean allowInvitationsOnlyForBuddies)Set to true if only buddies can be invited by a client side JoinRoomInvitationRequest, false otherwise.voidsetBuddyListManager(BuddyListManager buddyListManager)INTERNALvoidsetClientAllowedToOverridRoomEvents(boolean flag)Deprecated.voidsetCustomLogin(boolean flag)Set the Zone as Custom login.voidsetDBManager(IDBManager manager)INTERNALvoidsetDefaultGroups(java.util.List<java.lang.String> groupIDs)voidsetDefaultPlayerIdGeneratorClassName(java.lang.String className)voidsetEncrypted(boolean value)Toggles the protocol cryptography.voidsetExtension(ISFSExtension extension)INTERNALvoidsetFilterBuddyMessages(boolean flag)If turned on the Zone will apply the Words Filter to Buddy messagesvoidsetFilterChain(SystemRequest requestId, ISystemFilterChain chain)Set a SystemFilterChain for a specific SystemController's Request.voidsetFilterPrivateMessages(boolean flag)Toggle the filtering of private messages via the Words Filter.voidsetFilterRoomNames(boolean flag)Toggle the filtering of Room names via the Words Filter.voidsetFilterUserNames(boolean flag)Toggle the filtering of User names via the Words Filter at login time.voidsetForceLogout(boolean flag)If turned on it allows a User to connect from another location while another connection is already active.voidsetGeoLocationEnabled(boolean value)Toggles geolocation for clients.voidsetGuestUserAllowed(boolean flag)Toggles the Zone guest users (login with no name and no password).voidsetGuestUserNamePrefix(java.lang.String prefix)Set the prefix used by the system to auto-generate guest user names.voidsetHidden(boolean flag)INTERNALvoidsetId(int id)A numeric ID used by the AdminTool.voidsetLagMonitorKeepAlive(boolean value)Resets the the Users' idle timer for every client side LagMonitor request, when set to true;voidsetMaxAllowedRooms(int max)Set the maximum number of Rooms that can be created in the Room.voidsetMaxAllowedUsers(int max)Set the maximum number of users allowed to join the Zone.voidsetMaxFailedLogins(int value)Set the max number of login attempts (in the same session) a user can fail before being disconnected.voidsetMaxFindRoomResults(int value)Set the max number of "FindRoom" results for a client request.voidsetMaxFindUserResults(int value)Set the max number of "FindUser" results for a client request.voidsetMaxInvitationsPerRequest(int maxInvitationsPerRequest)Set the max number of people that can be invited a by a single client side JoinRoomInvitationRequestvoidsetMaxRoomNameChars(int maxRoomNameChars)Set the maximum number of characters allowed for a Room namevoidsetMaxRoomsCreatedPerUserLimit(int max)Set the maximum number of Rooms that a User can create at once.voidsetMaxRoomVariablesAllowed(int max)Set the maximum number of Room variables allowed in the RoomvoidsetMaxUserIdleTime(int seconds)Set the max allowed idle time for a User.voidsetMaxUserVariablesAllowed(int max)Set the maximum number of User Variables allowed for each User.voidsetMinRoomNameChars(int minRoomNameChars)Set the minimum number of characters allowed for a Room namevoidsetPrivilegeManager(PrivilegeManager privilegeManager)voidsetProperty(java.lang.Object key, java.lang.Object value)Properties are custom values that can be added or removed from the Zone at run-time.voidsetPublicGroups(java.util.List<java.lang.String> groupIDs)voidsetUploadEnabled(boolean val)Switches on/off the ability to upload data via HTTP.voidsetUserCountChangeUpdateInterval(int interval)Set the rate (in ms.) at which the UserCountUpdates events are fired to the clients.voidsetUserReconnectionSeconds(int seconds)Set the amount of seconds available for a User to reconnect to the system in case their socket connection goes down.voidsetZoneManager(com.smartfoxserver.v2.entities.managers.IZoneManager manager)java.lang.StringtoString()voidvalidateUserName(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:
getRoomManagerin interfaceZone- Returns:
- the Room Manager
-
getUserManager
public com.smartfoxserver.v2.entities.managers.IUserManager getUserManager()
- Specified by:
getUserManagerin interfaceZone
-
containsGroup
public boolean containsGroup(java.lang.String groupId)
Check if the Zone contains the specified Group- Specified by:
containsGroupin 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:
containsPublicGroupin 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:
createRoomin interfaceZone- Throws:
SFSCreateRoomException
-
createRoom
public Room createRoom(CreateRoomSettings params) throws SFSCreateRoomException
Use theSFSApi.createRoom(Zone, CreateRoomSettings, User)method instead- Specified by:
createRoomin interfaceZone- Throws:
SFSCreateRoomException
-
changeRoomName
public void changeRoomName(Room room, java.lang.String newName) throws SFSRoomException
- Specified by:
changeRoomNamein interfaceZone- Throws:
SFSRoomException
-
changeRoomPasswordState
public void changeRoomPasswordState(Room room, java.lang.String password)
- Specified by:
changeRoomPasswordStatein interfaceZone
-
changeRoomCapacity
public void changeRoomCapacity(Room room, int newMaxUsers, int newMaxSpect)
- Specified by:
changeRoomCapacityin interfaceZone
-
addDisabledSystemEvent
public void addDisabledSystemEvent(java.lang.String eventID)
Description copied from interface:ZoneINTERNAL- Specified by:
addDisabledSystemEventin interfaceZone
-
addRoom
public void addRoom(Room room) throws SFSTooManyRoomsException
Description copied from interface:ZoneINTERNALInstead use
SFSApi.createRoom(Zone, CreateRoomSettings, User)- Specified by:
addRoomin 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:
getGuestUserNamePrefixin interfaceZone- Returns:
- the user name prefix
-
getUserCount
public int getUserCount()
Get the current amount of Users connected to the Zone- Specified by:
getUserCountin interfaceZone- Returns:
- the amount of Users connected to the Zone
-
getTotalRoomCount
public int getTotalRoomCount()
- Specified by:
getTotalRoomCountin interfaceZone
-
getGameRoomCount
public int getGameRoomCount()
- Specified by:
getGameRoomCountin interfaceZone
-
getMaxAllowedRooms
public int getMaxAllowedRooms()
The maximum number of Rooms that can be created in the Room.- Specified by:
getMaxAllowedRoomsin 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:
getMaxUserVariablesAllowedin 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:
getMaxAllowedUsersin 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:
getMaxRoomsCreatedPerUserLimitin 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:
getPropertyin 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:
removePropertyin 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:
getPublicGroupsin 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:
getDefaultGroupsin 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:
getRoomByIdin 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:
getRoomByNamein 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:
getRoomListin 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:
getRoomListFromGroupin 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:ZoneObtain a Room list generated by merging all Rooms from the provided group names- Specified by:
getRoomListFromGroupListin 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:
getUserByIdin 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:
getUserByNamein 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:
getUserBySessionin 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:
getUserCountChangeUpdateIntervalin interfaceZone- Returns:
- the interval in milliseconds between each UserCountUpdate
-
getUCountThrottler
public com.smartfoxserver.v2.util.IResponseThrottler getUCountThrottler()
Description copied from interface:ZoneINTERNAL- Specified by:
getUCountThrottlerin interfaceZone
-
getDefaultPlayerIdGeneratorClassName
public java.lang.String getDefaultPlayerIdGeneratorClassName()
- Specified by:
getDefaultPlayerIdGeneratorClassNamein interfaceZone
-
setDefaultPlayerIdGeneratorClassName
public void setDefaultPlayerIdGeneratorClassName(java.lang.String className)
- Specified by:
setDefaultPlayerIdGeneratorClassNamein interfaceZone
-
isUploadEnabled
public boolean isUploadEnabled()
True if the Zone supports HTTP uploads.- Specified by:
isUploadEnabledin 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_UPLOADevent to be fired at Zone Level.- Specified by:
setUploadEnabledin interfaceZone
-
isLagMonitorKeepAlive
public boolean isLagMonitorKeepAlive()
Description copied from interface:ZoneReturns true if the LagMonitor requests are also actively resetting the User's idle timer- Specified by:
isLagMonitorKeepAlivein interfaceZone
-
setLagMonitorKeepAlive
public void setLagMonitorKeepAlive(boolean value)
Description copied from interface:ZoneResets the the Users' idle timer for every client side LagMonitor request, when set to true;- Specified by:
setLagMonitorKeepAlivein 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:
isFilterChainInitedin 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:
resetSystemFilterChainin interfaceZone
-
isHidden
public boolean isHidden()
Description copied from interface:ZoneINTERNAL
-
setHidden
public void setHidden(boolean flag)
Description copied from interface:ZoneINTERNAL
-
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:
getFilterChainin 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:
setFilterChainin interfaceZone- Parameters:
requestId- the SystemController request Idchain- the filter chain- See Also:
SysControllerFilterChain,SysControllerFilter
-
getExtension
public ISFSExtension getExtension()
INTERNAL- Specified by:
getExtensionin interfaceZone
-
setExtension
public void setExtension(ISFSExtension extension)
Description copied from interface:ZoneINTERNAL- Specified by:
setExtensionin 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:
getUserReconnectionSecondsin 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:
setUserReconnectionSecondsin 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:
getMaxUserIdleTimein 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:
setMaxUserIdleTimein 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:
getUsersInGroupin 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:
getSessionsInGroupin 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:ZoneGet a list of Sessions listening for events in a specific Group- Specified by:
getSessionsListeningToGroupin 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:
getSessionListin 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:
getUserListin interfaceZone- Returns:
- the list of Users logged in the Zone
-
getZoneManager
public com.smartfoxserver.v2.entities.managers.IZoneManager getZoneManager()
- Specified by:
getZoneManagerin 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:
isClientAllowedToOverridRoomEventsin 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:
isCustomLoginin 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:
isForceLogoutin 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:
isGuestUserAllowedin interfaceZone- Returns:
- true if the Zone allows guests
- See Also:
Zone.getGuestUserNamePrefix()
-
isSystemEventAllowed
public boolean isSystemEventAllowed(java.lang.String eventID)
INTERNAL- Specified by:
isSystemEventAllowedin interfaceZone
-
isFilterUserNames
public boolean isFilterUserNames()
If turned on the Zone will apply the Words Filter to User names provided at login time- Specified by:
isFilterUserNamesin 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:
isFilterRoomNamesin 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:
setFilterRoomNamesin interfaceZone- Parameters:
flag- a boolean
-
isFilterBuddyMessages
public boolean isFilterBuddyMessages()
Toggle the filtering of Buddy messages via the Words Filter.- Specified by:
isFilterBuddyMessagesin 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:
setFilterBuddyMessagesin interfaceZone
-
containsProperty
public boolean containsProperty(java.lang.Object key)
Checks the existance of a Zone property- Specified by:
containsPropertyin 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:
registerEventsForRoomGroupin 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:
isGroupEventSetin 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:
getGroupEventsin interfaceZone
-
removeDisabledSystemEvent
public void removeDisabledSystemEvent(java.lang.String eventID)
Description copied from interface:ZoneINTERNAL- Specified by:
removeDisabledSystemEventin interfaceZone
-
removeRoom
public void removeRoom(int roomId)
- Specified by:
removeRoomin interfaceZone
-
removeRoom
public void removeRoom(java.lang.String name)
- Specified by:
removeRoomin interfaceZone
-
removeRoom
public void removeRoom(Room room)
- Specified by:
removeRoomin interfaceZone
-
checkAndRemove
public void checkAndRemove(Room room)
- Specified by:
checkAndRemovein interfaceZone
-
removeUserFromRoom
public void removeUserFromRoom(User user, Room room)
- Specified by:
removeUserFromRoomin interfaceZone
-
getMinRoomNameChars
public int getMinRoomNameChars()
The minimum number of characters allowed for Room name- Specified by:
getMinRoomNameCharsin 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:
setMinRoomNameCharsin 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:
getMaxRoomNameCharsin 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:
setMaxRoomNameCharsin 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:ZoneA numeric ID used by the AdminTool. The true identifier of a Zone is its name
-
setClientAllowedToOverridRoomEvents
public void setClientAllowedToOverridRoomEvents(boolean flag)
Deprecated.- Specified by:
setClientAllowedToOverridRoomEventsin interfaceZone
-
setCustomLogin
public void setCustomLogin(boolean flag)
Description copied from interface:ZoneSet the Zone as Custom login. If turned on the developer's Extension will be able to take control over the login process.- Specified by:
setCustomLoginin interfaceZone- See Also:
SFSEvent,SFSEventType
-
setForceLogout
public void setForceLogout(boolean flag)
Description copied from interface:ZoneIf 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:
setForceLogoutin 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:
setGuestUserAllowedin 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:
setFilterUserNamesin 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:
setGuestUserNamePrefixin interfaceZone
-
setMaxAllowedRooms
public void setMaxAllowedRooms(int max)
Set the maximum number of Rooms that can be created in the Room.- Specified by:
setMaxAllowedRoomsin 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:
setMaxAllowedUsersin 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:
setMaxUserVariablesAllowedin 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:
setMaxRoomsCreatedPerUserLimitin 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:
setPropertyin 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:
setPublicGroupsin interfaceZone
-
setDefaultGroups
public void setDefaultGroups(java.util.List<java.lang.String> groupIDs)
- Specified by:
setDefaultGroupsin interfaceZone
-
setUserCountChangeUpdateInterval
public void setUserCountChangeUpdateInterval(int interval)
Set the rate (in ms.) at which the UserCountUpdates events are fired to the clients.- Specified by:
setUserCountChangeUpdateIntervalin 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:
setZoneManagerin interfaceZone
-
validateUserName
public void validateUserName(java.lang.String name) throws SFSException- Specified by:
validateUserNamein interfaceZone- Throws:
SFSException
-
getFloodFilter
public IFloodFilter getFloodFilter()
INTERNAL- Specified by:
getFloodFilterin interfaceZone
-
getWordFilter
public IWordFilter getWordFilter()
INTERNAL- Specified by:
getWordFilterin interfaceZone
-
removeAllUsers
public void removeAllUsers()
- Specified by:
removeAllUsersin interfaceZone
-
removeUser
public void removeUser(int userId)
INTERNALInstead use
SFSApi.disconnectUser(User)- Specified by:
removeUserin interfaceZone
-
removeUser
public void removeUser(ISession session)
INTERNALInstead use
SFSApi.disconnect(ISession)- Specified by:
removeUserin interfaceZone
-
removeUser
public void removeUser(java.lang.String userName)
INTERNALInstead use
SFSApi.disconnectUser(User)- Specified by:
removeUserin interfaceZone
-
removeUser
public void removeUser(User user)
INTERNALInstead use
SFSApi.disconnectUser(User)- Specified by:
removeUserin 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:
getMaxRoomVariablesAllowedin 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:
setMaxRoomVariablesAllowedin 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:
getPrivilegeManagerin interfaceZone
-
setPrivilegeManager
public void setPrivilegeManager(PrivilegeManager privilegeManager)
- Specified by:
setPrivilegeManagerin interfaceZone
-
getBuddyListManager
public BuddyListManager getBuddyListManager()
INTERNALInstead use
SFSBuddyApi- Specified by:
getBuddyListManagerin interfaceZone
-
setBuddyListManager
public void setBuddyListManager(BuddyListManager buddyListManager)
INTERNAL- Specified by:
setBuddyListManagerin interfaceZone
-
getDBManager
public IDBManager getDBManager()
Obtain a reference to the Zone's Database Manager.- Specified by:
getDBManagerin interfaceZone- See Also:
SFSDBManager
-
setDBManager
public void setDBManager(IDBManager manager)
Description copied from interface:ZoneINTERNAL- Specified by:
setDBManagerin interfaceZone
-
isFilterPrivateMessages
public boolean isFilterPrivateMessages()
If turned on the Zone will apply the Words Filter to private messages- Specified by:
isFilterPrivateMessagesin 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:
setFilterPrivateMessagesin 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:
loginin interfaceZone- Throws:
SFSLoginException
-
getRoomListData
public ISFSArray getRoomListData()
Description copied from interface:ZoneINTERNAL- Specified by:
getRoomListDatain interfaceZone
-
getRoomListData
public ISFSArray getRoomListData(java.util.List<java.lang.String> groupIds)
Description copied from interface:ZoneINTERNAL- Specified by:
getRoomListDatain interfaceZone
-
toString
public java.lang.String toString()
- Overrides:
toStringin 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:
initRoomPersistencein interfaceZoneconfig- 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:
getRoomPersistenceApiin 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:
isEncryptedin 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:
setEncryptedin 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:
getMaxInvitationsPerRequestin 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:
setMaxInvitationsPerRequestin 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:
isAllowInvitationsOnlyForBuddiesin 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:
setAllowInvitationsOnlyForBuddiesin interfaceZone
-
getMaxFailedLogins
public int getMaxFailedLogins()
Description copied from interface:ZoneThe max number of login attempts (in the same session) a user can fail before being disconnected.- Specified by:
getMaxFailedLoginsin 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:ZoneSet the max number of login attempts (in the same session) a user can fail before being disconnected.- Specified by:
setMaxFailedLoginsin 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:ZoneToggles geolocation for clients.- Specified by:
isGeoLocationEnabledin interfaceZone- Returns:
- true if geolocation is enabled in this Zone
-
setGeoLocationEnabled
public void setGeoLocationEnabled(boolean value)
Description copied from interface:ZoneToggles geolocation for clients.NOTE:IP address geolocation is done via a local database so the added performance cost is negligible.
- Specified by:
setGeoLocationEnabledin interfaceZone- Parameters:
value- true to enable the geolocation service, false to turn it off. Default = false
-
getMaxFindUserResults
public int getMaxFindUserResults()
Description copied from interface:ZoneGet the max number of "Find User" results for a client request. Default is 50.- Specified by:
getMaxFindUserResultsin interfaceZone
-
setMaxFindUserResults
public void setMaxFindUserResults(int value)
Description copied from interface:ZoneSet the max number of "FindUser" results for a client request. Default is 50.- Specified by:
setMaxFindUserResultsin interfaceZone
-
getMaxFindRoomResults
public int getMaxFindRoomResults()
Description copied from interface:ZoneGet the max number of "FindRoom" results for a client request. Default is 50.- Specified by:
getMaxFindRoomResultsin interfaceZone
-
setMaxFindRoomResults
public void setMaxFindRoomResults(int value)
Description copied from interface:ZoneSet the max number of "FindRoom" results for a client request. Default is 50.- Specified by:
setMaxFindRoomResultsin interfaceZone
-
-