it.gotoandplay.smartfoxserver.data
Class Room

java.lang.Object
  extended by it.gotoandplay.smartfoxserver.data.Room

public class Room
extends java.lang.Object

Room Class

Version:
1.6

Field Summary
 java.util.HashMap properties
           
 
Constructor Summary
Room(java.lang.String name, int maxUsers, boolean isTemp, boolean isGame, boolean isPrivate, java.lang.String password, java.lang.String zone)
          Full Constructor
Room(java.lang.String name, int maxUsers, boolean isTemp, java.lang.String zone)
          Basic Constructor
 
Method Summary
 boolean contains(java.lang.String name)
          Check if the room contains a certain user
 boolean deleteVariable(java.lang.String vName, User owner)
           
 void destroyExtensions()
          Destroy all extensions for this room
 User[] getAllUsers()
          Get all the users in the Room
 java.util.LinkedList getChannellList()
          Get a list of the SocketChannels in this room
 java.nio.channels.SocketChannel getCreator()
           
 it.gotoandplay.smartfoxserver.extensions.ExtensionManager getExtManager()
           
 int getId()
          Get room id
 int getMaxSpectator()
           
 int getMaxUsers()
          Get the max number of users allowed
 java.lang.String getName()
          getName()
 java.lang.String getPassword()
          Get the optional room password
 int getSpectatorCount()
           
 boolean getUcountUpdates()
          Get the status of the "uCount" server updates
 int getUserCount()
           
 java.lang.Object[] getUserList()
          Return an array of users
 RoomVariable getVariable(java.lang.String varName)
          Get a room variable
 java.util.LinkedList getVariableNames()
           
 java.util.HashMap getVariables()
          Get a map of variables
 java.lang.String getXmlUserList()
          Get xml formatted userList XML format is: hello 100
 java.lang.String getXmlVariable(java.lang.String varName)
           
 java.lang.String getXmlVarList()
           
 java.lang.String getZone()
          Get the parent zone
 int howManyUsers()
           
 boolean isGame()
           
 boolean isLimbo()
           
 boolean isPrivate()
           
 boolean isTemp()
           
 void join(User u, java.lang.String pwd, boolean isSpectator)
           
 boolean removeUser(User u, boolean updateUserRoomList, boolean destroyVars)
           
static void resetRoomStaticData()
          Reset the autoId when the server is restarted
 void setCreator(java.nio.channels.SocketChannel ch)
           
 void setGame()
          Set as a game room
 void setLimbo(boolean isLimbo)
           
 void setMaxSpectators(int s)
          Set the max number of spectators
 void setName(java.lang.String name)
          setName()
 void setPassword(java.lang.String pw)
          Set the room password
 void setUcountUpdates(boolean b)
          Turn on/off the "uCount" server updates
 boolean setVariable(java.lang.String vn, java.lang.String vt, java.lang.String vv, boolean pr, boolean ps, User owner, boolean setOwnership)
          Set a Room Variable
 int switchSpectator(User u)
          Switch a user from spectator to player (available only in game rooms with spectators)
 void updateUserCount()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

properties

public java.util.HashMap properties
Constructor Detail

Room

public Room(java.lang.String name,
            int maxUsers,
            boolean isTemp,
            java.lang.String zone)
Basic Constructor

Parameters:
name - = room name
maxUsers - = max number of users allowed
isTemp - = marks the room as temporary if = true

Room

public Room(java.lang.String name,
            int maxUsers,
            boolean isTemp,
            boolean isGame,
            boolean isPrivate,
            java.lang.String password,
            java.lang.String zone)
Full Constructor

Parameters:
name - the room name
maxUsers - max number of users allowed in the room
isTemp - temp room
isGame - game room
isPrivate - private room
password - an optional password
zone - the zone name
Method Detail

destroyExtensions

public void destroyExtensions()
Destroy all extensions for this room


switchSpectator

public int switchSpectator(User u)
Switch a user from spectator to player (available only in game rooms with spectators)

Parameters:
u - the User
Returns:
the id of the player

setMaxSpectators

public void setMaxSpectators(int s)
Set the max number of spectators

Parameters:
s -

getMaxSpectator

public int getMaxSpectator()
Returns:
the max number of spectators

setUcountUpdates

public void setUcountUpdates(boolean b)
Turn on/off the "uCount" server updates

Parameters:
b -

getUcountUpdates

public boolean getUcountUpdates()
Get the status of the "uCount" server updates

Returns:
the flag

getExtManager

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

join

public void join(User u,
                 java.lang.String pwd,
                 boolean isSpectator)
          throws it.gotoandplay.smartfoxserver.exceptions.JoinRoomException
Throws:
it.gotoandplay.smartfoxserver.exceptions.JoinRoomException

getXmlUserList

public java.lang.String getXmlUserList()
Get xml formatted userList XML format is: hello 100


getUserList

public java.lang.Object[] getUserList()
Return an array of users


getAllUsers

public User[] getAllUsers()
Get all the users in the Room

Returns:
an array of Users

getXmlVarList

public java.lang.String getXmlVarList()

getXmlVariable

public java.lang.String getXmlVariable(java.lang.String varName)

getVariableNames

public java.util.LinkedList getVariableNames()

getVariables

public java.util.HashMap getVariables()
Get a map of variables

Returns:
the HashMap with the variables

getVariable

public RoomVariable getVariable(java.lang.String varName)
Get a room variable

Parameters:
varName - the name of the variable
Returns:
the variable

getId

public int getId()
Get room id

Returns:
the id

getZone

public java.lang.String getZone()
Get the parent zone

Returns:
the zone name

getPassword

public java.lang.String getPassword()
Get the optional room password

Returns:
the password

getChannellList

public java.util.LinkedList getChannellList()
Get a list of the SocketChannels in this room

Returns:
a LinkedList of Channels for all users in this room

getName

public java.lang.String getName()
getName()

Returns:
the room name

setName

public void setName(java.lang.String name)
setName()

Parameters:
name - the name of the room

isPrivate

public boolean isPrivate()
Returns:
isPrivate flag

isTemp

public boolean isTemp()
Returns:
isTemp flag

isGame

public boolean isGame()
Returns:
isGame flag

setGame

public void setGame()
Set as a game room


setPassword

public void setPassword(java.lang.String pw)
Set the room password

Parameters:
pw - the password

getMaxUsers

public int getMaxUsers()
Get the max number of users allowed

Returns:
the max number

getUserCount

public int getUserCount()
Returns:
The number of clients in this room

getSpectatorCount

public int getSpectatorCount()
Returns:
the number of spectators in the room

removeUser

public boolean removeUser(User u,
                          boolean updateUserRoomList,
                          boolean destroyVars)

setVariable

public boolean setVariable(java.lang.String vn,
                           java.lang.String vt,
                           java.lang.String vv,
                           boolean pr,
                           boolean ps,
                           User owner,
                           boolean setOwnership)
Set a Room Variable

Parameters:
vn - var name
vt - var type
vv - var value
pr - persistent flag
ps - private flag
owner - the owner User
setOwnership - change the ownership flag
Returns:
true if the variable was created/updated
Since:
SFS 1.3.5 and later

deleteVariable

public boolean deleteVariable(java.lang.String vName,
                              User owner)

updateUserCount

public void updateUserCount()

howManyUsers

public int howManyUsers()

setCreator

public void setCreator(java.nio.channels.SocketChannel ch)

getCreator

public java.nio.channels.SocketChannel getCreator()

contains

public boolean contains(java.lang.String name)
Check if the room contains a certain user

Parameters:
name - the user name
Returns:
true if the user was found

resetRoomStaticData

public static void resetRoomStaticData()
Reset the autoId when the server is restarted


isLimbo

public boolean isLimbo()
Returns:
Returns the isLimbo.

setLimbo

public void setLimbo(boolean isLimbo)
Parameters:
isLimbo - The isLimbo to set.