it.gotoandplay.smartfoxserver.data
Class Zone

java.lang.Object
  extended by it.gotoandplay.smartfoxserver.data.Zone
All Implemented Interfaces:
it.gotoandplay.smartfoxserver.lib.IService

public class Zone
extends java.lang.Object
implements it.gotoandplay.smartfoxserver.lib.IService

Zone Class: A Zone represents an "application" running in the server. SmartFoxServer can run many multiple Zones simultaneously, where each application is isolated from the others.

Zones provide high level services to the developer like the DbManager for connecting to databases, the BuddyListManager for handling buddy lists etc...


Field Summary
 DbManager dbManager
          the database manager object
 it.gotoandplay.smartfoxserver.data.ModeratorManager modManager
           
 java.lang.String roomNameAvoidChars
           
static int STATUS_ACTIVE
           
static int STATUS_INACTIVE
           
 java.lang.String userNameAvoidChars
           
 
Constructor Summary
Zone(java.lang.String name, java.lang.String customLogin)
          Default constructor
 
Method Summary
 void activate()
           
 void addBuddy(java.lang.String owner, java.lang.String buddyName)
          Add a buddy to a buddyList
 void addDisabledEvent(java.lang.String evt)
          Add a new event in the disable sysHandler map
 void addDisabledSysAction(java.lang.String action)
          Adds a new SysHandler to be disabled for this zone
 void addName(java.lang.String name, java.lang.Integer uid)
           
 void addRoom(Room rm)
           
 boolean checkBuddy(java.lang.String name)
           
 void clearAllExtensions()
           
 void clearBuddyList(java.lang.String owner)
          Deprecated.  
 void clearDisabledEvents()
          Clear the list of disable sysHandler events
 void clearDisabledSysActions()
           
 void deactivate()
           
 void destroy(java.lang.Object param)
           
 void destroyVariables(User u)
           
 java.util.LinkedList getAllUsersInZone()
           
 int getAutoJoinRoom()
           
 BuddyListManager getBuddyManager()
          Return the BuddyListManager for this zone
 java.nio.channels.SocketChannel getChannelFromName(java.lang.String name)
           
 java.util.LinkedList getChannelList()
           
 boolean getCountUpdate()
           
 boolean getEmptyNames()
           
 AbstractExtension getExtension(java.lang.String name)
          Get an extension from its name
 it.gotoandplay.smartfoxserver.extensions.ExtensionManager getExtManager()
           
 int getMaxRoomNameLen()
           
 int getMaxRooms()
           
 int getMaxRoomsPerUser()
          Get the maximum number of rooms that can be created by a single user
 int getMaxUserNameLen()
           
 int getMaxUsers()
           
 java.lang.String getName()
           
 Room getRoom(int roomId)
          Return a room object from this zone
 Room getRoomByName(java.lang.String name)
          Find a room from its name
 int getRoomCount()
           
 java.util.LinkedList getRoomList()
           
 java.lang.Object[] getRooms()
           
 boolean getRoomUpdates()
           
 int getStatus()
           
 User getUserByName(java.lang.String name)
          Get a user from its name
 int getUserCount()
          New since version 1.4.0 no need to use the above code.
 java.lang.Integer getUserIdByName(java.lang.String name)
          Get a User id from its name
 java.util.List getUserList()
          Get the full list of users connected to this zone
 java.util.Map getUserNames()
          Deprecated.  
 boolean getVarsOnRoomList()
           
 java.lang.String getXmlBuddy(java.lang.String name)
           
 boolean hasBuddyList()
           
 boolean hasCustomLogin()
           
 void init(java.lang.Object param)
           
 void initBuddyList(int listLength, IBuddyListPersister persister)
           
 boolean isActive()
           
 boolean isAutoReloadExtensions()
           
 boolean isEventDisabled(java.lang.String evt)
          Checks if a certain event is disabled Event names are keep all lower-case to avoid case sensitiveness problems
 boolean isPrivMsgInternalEventEnabled()
          Get the status of the PrivMsg internal event
 boolean isPubMsgInternalEventEnabled()
          Get the status of the PubMsg internal event
 boolean isSysActionDisabled(java.lang.String action)
           
 boolean isThereRoom()
           
 it.gotoandplay.smartfoxserver.data.buddylist.LoadableBuddyList loadBuddyList(java.lang.String owner)
          Last update November 6th, 2007 Version 1.6.0b5
 boolean removeBuddy(java.lang.String owner, java.lang.String buddyName)
          Remove buddy from BuddyList
 void removeName(java.lang.String name, User u)
           
 void removeRoom(Room rm, boolean exitingAllRooms)
           
 boolean roomNameAlreadyExist(java.lang.String roomName)
           
 void saveAllBuddyLists()
          Save all buddy lists.
 void saveBuddyList(java.lang.String name)
          Save a buddyList
 void setAutoJoinRoom(int roomId)
          Set the id of the auto-join room
 void setAutoReloadExtensions(boolean autoReloadExtensions)
           
 void setCountUpdate(boolean b)
           
 void setEmptyNames(boolean b)
           
 void setMaxRoomNameLen(int maxRoomNameLen)
           
 void setMaxRooms(int i)
          Set the max number of Rooms allowed for this Zone
 void setMaxRoomsPerUser(int m)
          Set the maximum number of rooms that can be created by a single user
 void setMaxUserNameLen(int maxUserNameLen)
           
 void setMaxUsers(int i)
          Set the max number of users allowed for this Zone
 void setPrivMsgInternalEvent(boolean b)
          Enable / Disable "privMsg" events in extensions
 void setPubMsgInternalEvent(boolean b)
          Enable / Disable "pubMsg" events in extensions
 void setRoomUpdates(boolean b)
           
 void setVarsOnRoomList(boolean b)
           
 boolean validateUserName(java.lang.String name)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STATUS_ACTIVE

public static final int STATUS_ACTIVE
See Also:
Constant Field Values

STATUS_INACTIVE

public static final int STATUS_INACTIVE
See Also:
Constant Field Values

userNameAvoidChars

public java.lang.String userNameAvoidChars

roomNameAvoidChars

public java.lang.String roomNameAvoidChars

modManager

public it.gotoandplay.smartfoxserver.data.ModeratorManager modManager

dbManager

public DbManager dbManager
the database manager object

See Also:
DbManager
Constructor Detail

Zone

public Zone(java.lang.String name,
            java.lang.String customLogin)
Default constructor

Parameters:
name - zone name
customLogin - true if the Zone handles the login process with a server side extension
Method Detail

init

public void init(java.lang.Object param)
Specified by:
init in interface it.gotoandplay.smartfoxserver.lib.IService

destroy

public void destroy(java.lang.Object param)
Specified by:
destroy in interface it.gotoandplay.smartfoxserver.lib.IService

addDisabledEvent

public void addDisabledEvent(java.lang.String evt)
Add a new event in the disable sysHandler map

Parameters:
evt - the event name
Since:
version 1.4.0b3

isEventDisabled

public boolean isEventDisabled(java.lang.String evt)
Checks if a certain event is disabled Event names are keep all lower-case to avoid case sensitiveness problems

Parameters:
evt - the event name
Returns:
true if event is disabled
Since:
version 1.4.0b3

clearDisabledEvents

public void clearDisabledEvents()
Clear the list of disable sysHandler events

Since:
version 1.4.0b3

addDisabledSysAction

public void addDisabledSysAction(java.lang.String action)
Adds a new SysHandler to be disabled for this zone

Parameters:
action - the name of the action

isSysActionDisabled

public boolean isSysActionDisabled(java.lang.String action)

clearDisabledSysActions

public void clearDisabledSysActions()

isPubMsgInternalEventEnabled

public boolean isPubMsgInternalEventEnabled()
Get the status of the PubMsg internal event

Returns:
the status of the "PubMsg" internal event

setPubMsgInternalEvent

public void setPubMsgInternalEvent(boolean b)
Enable / Disable "pubMsg" events in extensions

Parameters:
b -

isPrivMsgInternalEventEnabled

public boolean isPrivMsgInternalEventEnabled()
Get the status of the PrivMsg internal event

Returns:
the status of the "PrivMsg" internal event

setPrivMsgInternalEvent

public void setPrivMsgInternalEvent(boolean b)
Enable / Disable "privMsg" events in extensions

Parameters:
b -

getName

public java.lang.String getName()
Returns:
the zone name

hasCustomLogin

public boolean hasCustomLogin()
Returns:
true if this zone has custom login extension handler

getStatus

public int getStatus()
Returns:
the status of the current zone

getVarsOnRoomList

public boolean getVarsOnRoomList()
Returns:
the status of the roomListVars flag

setVarsOnRoomList

public void setVarsOnRoomList(boolean b)
Parameters:
b - set the status of roomListVars flag

getRoomUpdates

public boolean getRoomUpdates()

setRoomUpdates

public void setRoomUpdates(boolean b)

getExtManager

public it.gotoandplay.smartfoxserver.extensions.ExtensionManager getExtManager()

getBuddyManager

public BuddyListManager getBuddyManager()
Return the BuddyListManager for this zone

Returns:
the buddy list manager object

isActive

public boolean isActive()
Returns:
true if the current zone is active

getMaxRoomsPerUser

public int getMaxRoomsPerUser()
Get the maximum number of rooms that can be created by a single user

Returns:
the max number of rooms

setMaxRoomsPerUser

public void setMaxRoomsPerUser(int m)
Set the maximum number of rooms that can be created by a single user

Parameters:
m -

validateUserName

public boolean validateUserName(java.lang.String name)

addName

public void addName(java.lang.String name,
                    java.lang.Integer uid)

removeName

public void removeName(java.lang.String name,
                       User u)

destroyVariables

public void destroyVariables(User u)

clearAllExtensions

public void clearAllExtensions()

getExtension

public AbstractExtension getExtension(java.lang.String name)
Get an extension from its name

Parameters:
name - the name of the extension
Returns:
the extension
Since:
1.6.0

getChannelFromName

public java.nio.channels.SocketChannel getChannelFromName(java.lang.String name)

getUserByName

public User getUserByName(java.lang.String name)
Get a user from its name

Returns:
the user name
Since:
1.6.0

getUserIdByName

public java.lang.Integer getUserIdByName(java.lang.String name)
Get a User id from its name

Parameters:
name - the user name
Returns:
the user id

addRoom

public void addRoom(Room rm)
             throws it.gotoandplay.smartfoxserver.exceptions.CreateRoomException
Throws:
it.gotoandplay.smartfoxserver.exceptions.CreateRoomException

removeRoom

public void removeRoom(Room rm,
                       boolean exitingAllRooms)

deactivate

public void deactivate()

activate

public void activate()

setAutoJoinRoom

public void setAutoJoinRoom(int roomId)
Set the id of the auto-join room

Parameters:
roomId - the room id

getAutoJoinRoom

public int getAutoJoinRoom()
Returns:
the id of the autojoin room

getRoom

public Room getRoom(int roomId)
Return a room object from this zone


getRoomByName

public Room getRoomByName(java.lang.String name)
Find a room from its name

Parameters:
name - the room name
Returns:
the Room object

getRoomList

public java.util.LinkedList getRoomList()
Returns:
a list of rooms inside the Zone

getRooms

public java.lang.Object[] getRooms()

roomNameAlreadyExist

public boolean roomNameAlreadyExist(java.lang.String roomName)

getRoomCount

public int getRoomCount()
Returns:
the number of rooms

getUserCount

public int getUserCount()
New since version 1.4.0 no need to use the above code. The # of users in the Zone is determined by the size of userNames which represents the unique clients logged in


isThereRoom

public boolean isThereRoom()

getAllUsersInZone

public java.util.LinkedList getAllUsersInZone()
Returns:
a list with all SocketChannels in the Zone, but excludes users in game rooms

getChannelList

public java.util.LinkedList getChannelList()
Returns:
a list with all SocketChannels in the Zone

getUserList

public java.util.List getUserList()
Get the full list of users connected to this zone

Returns:
the List of users

getUserNames

public java.util.Map getUserNames()
Deprecated. 

since 1.6.3-M2

Returns:
a map of names

hasBuddyList

public boolean hasBuddyList()
Returns:
true if the Zone has an active buddy list

initBuddyList

public void initBuddyList(int listLength,
                          IBuddyListPersister persister)

addBuddy

public void addBuddy(java.lang.String owner,
                     java.lang.String buddyName)
              throws it.gotoandplay.smartfoxserver.exceptions.BuddyListException
Add a buddy to a buddyList

Throws:
it.gotoandplay.smartfoxserver.exceptions.BuddyListException

removeBuddy

public boolean removeBuddy(java.lang.String owner,
                           java.lang.String buddyName)
Remove buddy from BuddyList


loadBuddyList

public it.gotoandplay.smartfoxserver.data.buddylist.LoadableBuddyList loadBuddyList(java.lang.String owner)
                                                                             throws it.gotoandplay.smartfoxserver.exceptions.BuddyListException
Last update November 6th, 2007 Version 1.6.0b5

Throws:
it.gotoandplay.smartfoxserver.exceptions.BuddyListException

saveBuddyList

public void saveBuddyList(java.lang.String name)
Save a buddyList


saveAllBuddyLists

public void saveAllBuddyLists()
Save all buddy lists. Used before shutting down.


clearBuddyList

public void clearBuddyList(java.lang.String owner)
Deprecated. 


checkBuddy

public boolean checkBuddy(java.lang.String name)

getXmlBuddy

public java.lang.String getXmlBuddy(java.lang.String name)

getCountUpdate

public boolean getCountUpdate()

setCountUpdate

public void setCountUpdate(boolean b)

getMaxUsers

public int getMaxUsers()
Returns:
the maximum number of users for this Zone

setMaxUsers

public void setMaxUsers(int i)
Set the max number of users allowed for this Zone

Parameters:
i - the max number

getMaxRooms

public int getMaxRooms()
Returns:
the max number of Rooms allowed for this Zone

setMaxRooms

public void setMaxRooms(int i)
Set the max number of Rooms allowed for this Zone

Parameters:
i -

setEmptyNames

public void setEmptyNames(boolean b)

getEmptyNames

public boolean getEmptyNames()

getMaxRoomNameLen

public int getMaxRoomNameLen()
Returns:
Returns the maxRoomNameLen.

setMaxRoomNameLen

public void setMaxRoomNameLen(int maxRoomNameLen)
Parameters:
maxRoomNameLen - The maxRoomNameLen to set.

getMaxUserNameLen

public int getMaxUserNameLen()
Returns:
Returns the maxUserNameLen.

setMaxUserNameLen

public void setMaxUserNameLen(int maxUserNameLen)
Parameters:
maxUserNameLen - The maxUserNameLen to set.

isAutoReloadExtensions

public boolean isAutoReloadExtensions()

setAutoReloadExtensions

public void setAutoReloadExtensions(boolean autoReloadExtensions)