it.gotoandplay.smartfoxserver.data
Class User

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

public class User
extends java.lang.Object

User Class

Version:
1.6.0 update list Jan 25th 2007: added ignoreList and relative save, load methods

Field Summary
 int badwordsWarningCounter
           
 java.util.HashMap buddyVariables
           
 int floodCounter
           
 int floodWarningsCounter
           
 it.gotoandplay.smartfoxserver.data.ignorelist.UserIgnoreList ignoreList
           
 boolean isBeingKicked
           
 boolean isPlayer
           
 java.lang.String lastMessage
           
 int playerIndex
           
 java.util.HashMap properties
           
 int repeatedMsgCounter
           
 
Constructor Summary
User(java.nio.channels.SocketChannel channel, java.lang.String name, java.lang.String zone)
          Defualt constructor
 
Method Summary
 void addCreatedRoom(Room r)
           
 void addRoom(Room r)
           
 boolean buddyListChanged()
           
 void deleteVariable(java.lang.String name)
           
 void exitAllRooms()
           
 java.nio.channels.SocketChannel getChannel()
           
 java.lang.String getIpAddress()
           
 long getLastMessageTime()
           
 long getLoginTime()
           
 java.lang.String getName()
           
 int getPlayerIndex()
           
 int getPlayerIndex(Room r)
           
 int getPrivilege()
           
 int getRoom()
           
 int[] getRoomsConnected()
           
 int getRoomsConnectedCount()
           
 int getRoomsCreatedCount()
           
 int getUserId()
           
 UserVariable getVariable(java.lang.String varName)
          Get a User Variable
 java.util.LinkedList getVariableNames()
           
 java.util.HashMap getVariables()
           
 java.lang.String getXmlVarList()
           
 java.lang.String getZone()
           
 void initializeIgnoreList()
           
 void initUser()
           
 boolean isAdmin()
           
 boolean isBusyForChallenge()
           
 boolean isBusyForPlay()
           
 boolean isInRoom(int roomId)
          Return if the user is currently joined in the room
 boolean isModerator()
           
 boolean isSpectator()
           
 void loadIgnoreList()
           
 void removeCreatedRoom(Room r)
           
 void removeRoom(Room r)
           
static void resetUserStaticData()
          Reset the autoId when the server is restarted
 void saveIgnoreList()
           
 void setAsAdmin()
          Set the user as Admin
 void setAsModerator()
          Set the user as a moderator
 void setAsModerator(boolean b)
          Set the moderator flag
 void setBuddyListChanged()
           
 void setBusyForChallenge(boolean status)
           
 void setIsBusyForPlay(boolean status)
           
 void setPlayerIndex(Room r, int id)
           
 void setPrivilege(int p)
           
 boolean setVariable(java.lang.String vn, java.lang.String vv, java.lang.String vt)
           
 void updateMessageTime()
          Update the last message time
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

isPlayer

public boolean isPlayer

isBeingKicked

public boolean isBeingKicked

playerIndex

public int playerIndex

floodCounter

public int floodCounter

repeatedMsgCounter

public int repeatedMsgCounter

floodWarningsCounter

public int floodWarningsCounter

badwordsWarningCounter

public int badwordsWarningCounter

lastMessage

public java.lang.String lastMessage

properties

public java.util.HashMap properties

buddyVariables

public java.util.HashMap buddyVariables

ignoreList

public it.gotoandplay.smartfoxserver.data.ignorelist.UserIgnoreList ignoreList
Constructor Detail

User

public User(java.nio.channels.SocketChannel channel,
            java.lang.String name,
            java.lang.String zone)
Defualt constructor

Parameters:
channel - SocketChannel of the client
name - user name
zone - the initial zone
Method Detail

initUser

public void initUser()

initializeIgnoreList

public void initializeIgnoreList()

saveIgnoreList

public void saveIgnoreList()
                    throws it.gotoandplay.smartfoxserver.exceptions.IgnoreListException
Throws:
it.gotoandplay.smartfoxserver.exceptions.IgnoreListException

loadIgnoreList

public void loadIgnoreList()
                    throws it.gotoandplay.smartfoxserver.exceptions.IgnoreListException
Throws:
it.gotoandplay.smartfoxserver.exceptions.IgnoreListException

buddyListChanged

public boolean buddyListChanged()

setBuddyListChanged

public void setBuddyListChanged()

isSpectator

public boolean isSpectator()
Returns:
true if the user is a spectator (for game rooms)

setPlayerIndex

public void setPlayerIndex(Room r,
                           int id)

getPlayerIndex

public int getPlayerIndex()
Returns:
the player index

getPlayerIndex

public int getPlayerIndex(Room r)
Returns:
the player index for the user inside the Room r
if -1 is returned the playerIndex does not exist
if 0 is returned the room is not a game room
A valid playerIndex is always > 0

exitAllRooms

public void exitAllRooms()

addRoom

public void addRoom(Room r)

getRoomsConnected

public int[] getRoomsConnected()
Returns:
an array of room indexes where the user is joined

getRoomsConnectedCount

public int getRoomsConnectedCount()
Returns:
the number of rooms where the user is connected

getRoomsCreatedCount

public int getRoomsCreatedCount()
Returns:
the number of active rooms created by the user

getRoom

public int getRoom()

setPrivilege

public void setPrivilege(int p)

getPrivilege

public int getPrivilege()

isModerator

public boolean isModerator()
Returns:
true if the user is moderator

setAsModerator

public void setAsModerator()
Set the user as a moderator


setAsModerator

public void setAsModerator(boolean b)
Set the moderator flag

Parameters:
b - the status
Since:
version 1.4.0beta 4

isAdmin

public boolean isAdmin()
Returns:
true if the user is Admin

setAsAdmin

public void setAsAdmin()
Set the user as Admin


removeRoom

public void removeRoom(Room r)

addCreatedRoom

public void addCreatedRoom(Room r)

removeCreatedRoom

public void removeCreatedRoom(Room r)

getUserId

public int getUserId()
Returns:
the user id

getChannel

public java.nio.channels.SocketChannel getChannel()
Returns:
the SocketChannel of the user

getName

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

getZone

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

getLastMessageTime

public long getLastMessageTime()
Returns:
the last message time expressed in Unix time

getLoginTime

public long getLoginTime()
Returns:
the login time (Unix time format)

updateMessageTime

public void updateMessageTime()
Update the last message time


setVariable

public boolean setVariable(java.lang.String vn,
                           java.lang.String vv,
                           java.lang.String vt)

deleteVariable

public void deleteVariable(java.lang.String name)

isBusyForChallenge

public boolean isBusyForChallenge()

setBusyForChallenge

public void setBusyForChallenge(boolean status)

isBusyForPlay

public boolean isBusyForPlay()

setIsBusyForPlay

public void setIsBusyForPlay(boolean status)

getXmlVarList

public java.lang.String getXmlVarList()

getVariable

public UserVariable getVariable(java.lang.String varName)
Get a User Variable

Parameters:
varName -
Returns:
the UserVariable

getVariables

public java.util.HashMap getVariables()
Returns:
a HashMap of UserVariables with the name as the key

getVariableNames

public java.util.LinkedList getVariableNames()
Returns:
a list of UserVariables names

getIpAddress

public java.lang.String getIpAddress()
Returns:
the ip address of the client

resetUserStaticData

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


isInRoom

public boolean isInRoom(int roomId)
Return if the user is currently joined in the room

Parameters:
roomId - the id of the room
Returns:
true if the user is joined in the specified room, false otherwise