de.kosi.session
Class UserManager

java.lang.Object
  |
  +--de.kosi.session.UserManager

public class UserManager
extends java.lang.Object

This class maintains a list of users, that are online, or users that have disconnected a short while ago. While a user is online he gets pinged in certain intervals. When a user is disconnected and there are still listeners, waiting to be notiefied, if the user returns, the UserManager maintains a reference the user object until it times out. If the user comes back online, all listeners are notified of this event.

ChangeLog:

 $Log: UserManager.java,v $
 Revision 1.14  2001/08/28 10:43:17  meijer
 *** empty log message ***

 Revision 1.13  2001/08/21 14:15:22  betacarotine
 the computer player should be startable from the table now, but is not
 automatically removed from memory...

 Revision 1.12  2001/08/02 10:44:30  jiriki
 Worked on Tournament

 Revision 1.11  2001/07/20 14:37:08  jiriki
 Fixed Bug 440605

 Revision 1.10  2001/07/04 12:34:30  uid30828
 - Rubber score implemented
 - Inviting now working

 Revision 1.9  2001/06/23 13:44:44  jiriki
 Re-Added WaitBox

 Revision 1.8  2001/06/22 16:22:55  jiriki
 Removed Bug : Guests could not be invited.

 Revision 1.7  2001/06/12 17:14:33  jiriki
 - Reimplemented DistributedList to make filters working
 - Made ServertestCase working.

 Revision 1.6  2001/06/05 10:09:35  jiriki
 Implemented online-user list in foyer.

 Revision 1.5  2001/06/04 14:21:10  jiriki
 Made source more comliant to coding guidelines.

 Revision 1.4  2001/05/17 10:03:49  jiriki
 Removed bug in guest login (Guest user where never destroyed).

 Revision 1.3  2001/05/11 12:48:20  betacarotine
 started guest login implementation

 Revision 1.2  2001/05/09 18:55:21  jiriki
 Removed Bug 422612.

 Revision 1.1.1.1  2001/04/29 18:05:19  jiriki
 Imported sources from zola.

 Revision 1.20  2001/04/27 12:49:36  login
 Added Locale in user creation, improved game stopwatch

 Revision 1.19  2001/04/11 17:40:49  wombat
 Updated Documentation.

 Revision 1.18  2001/04/09 13:03:10  wombat
 Removed timeout from threadpool (did not work)

 Revision 1.17  2001/04/08 17:07:12  wombat
 Account Erstellung eingebaut

 Revision 1.16  2001/03/21 13:26:36  wombat
 - Removed bugs in Table
 - began implementation of stree client
 - updated documentation

 Revision 1.15  2001/03/20 18:17:31  wombat
 Added logging support

 Revision 1.14  2001/03/19 21:50:49  wombat
 - Worked on admin client.
 - improved shutdown sequence
 - removed bugs in login/logout sequence

 Revision 1.13  2001/03/18 17:32:04  wombat
 Changed database concept

 Revision 1.12  2001/03/15 22:41:28  wombat
 - Worked on server admin client mockup
 - fixed smaller bugs
 - removed User.getPassword() method (use checkPassword instead)

 Revision 1.11  2001/03/14 13:46:34  wombat
 Worked on Admin Tool. Removed deadlock while killing session

 Revision 1.10  2001/03/09 11:15:03  wombat
 Updated documentation.

 Revision 1.9  2001/03/08 17:12:27  wombat
 Implemented User database

 Revision 1.8  2001/03/07 14:21:03  wombat
 removed compiler errors

 Revision 1.7  2001/03/01 20:31:32  wombat
 Worked on table implementation / updated documentation

 Revision 1.6  2001/03/01 14:43:00  wombat
 Worked on table implementation.

 Revision 1.5  2001/02/25 23:16:05  wombat
 - deadlock vermeidung umgestellt.
 - ListenerList erstellt

 Revision 1.4  2001/02/06 11:32:50  wombat
 started ssl implementation

 Revision 1.3  2001/02/04 17:12:59  wombat
 - updated Documentation
 - continued implementation of UserManger

 

Version:
$Revision: 1.14 $ ($Date: 2001/08/28 10:43:17 $)
Author:
Jan-Ole Janssen, Niklas Mehner, Time Sticher

Field Summary
static int OFFLINE_TIMEOUT
          Time the user object is destroyed, after the user has disconnected.
static int PING_INTERVAL
          Interval the users are pinged in.
 
Method Summary
 void addPlayingUser(UserImpl user)
          Add a user to the list of currently playing users.
 UserImpl addUser(Session session, java.lang.String username, java.lang.String password, FoyerListener listener, int maxUsers)
          Add a user to the user manager.
 ComputerPlayerUserImpl createComputerPlayerUser()
          Creates a computer player user object.
 void createUser(java.lang.String username, java.lang.String email, java.util.Locale locale, int strength, java.util.TimeZone timeZone, java.lang.String biddingSystem)
          Create a new user account.
 void disconnectAll()
          Disconnect all users.
 DistributedList getOnlineUserList()
          Returns the distributed list of users, that are currently online.
 UserImpl getUser(java.lang.String username)
          Returns the foyer listener of an user.
static UserManager getUserManager()
          Returns the singleton instance of this class.
static void init()
           
 void inviteUser(java.lang.String username, User byUser, Table table, int direction)
          Invite an user to a table.
 boolean isUserPlaying(User user)
          Returns if a user is currently playing at a table or in a tournament.
 void removePlayingUser(UserImpl user)
          Remove a user from the list of currently playing users.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PING_INTERVAL

public static final int PING_INTERVAL
Interval the users are pinged in.

OFFLINE_TIMEOUT

public static final int OFFLINE_TIMEOUT
Time the user object is destroyed, after the user has disconnected.
Method Detail

addUser

public UserImpl addUser(Session session,
                        java.lang.String username,
                        java.lang.String password,
                        FoyerListener listener,
                        int maxUsers)
                 throws KosiAccessException
Add a user to the user manager. This loads the user from the database or updates the user object with the new session, if it already exists.
Parameters:
session - session for the user.
username - loginname of the user.
password - password.
listener - FoyerListener of the user.
maxUsers - Maximum number of users (this parameter should be removed).
Returns:
the user object
Throws:
KosiAccessException - if a wrong password is provided.

createUser

public void createUser(java.lang.String username,
                       java.lang.String email,
                       java.util.Locale locale,
                       int strength,
                       java.util.TimeZone timeZone,
                       java.lang.String biddingSystem)
                throws java.lang.IllegalArgumentException
Create a new user account.
Parameters:
username - The name for the new account. This name has to be unique.
email - E-Mail address for this account. An e-mail is send to this address, to test if the address is valid.
locale - Locale of the user.
strength - Strength of the user (one of the User.STRENGHT_* constants).
timeZone - Time zone the user lives in.
biddingSystem - Bidding system. This is used to set up first conventions for the user.
Throws:
java.lang.IllegalArgumentException - If a invalid username or email is specified.

createComputerPlayerUser

public ComputerPlayerUserImpl createComputerPlayerUser()
Creates a computer player user object.

disconnectAll

public void disconnectAll()
Disconnect all users.

init

public static void init()

getUserManager

public static UserManager getUserManager()
Returns the singleton instance of this class.
Returns:
User Manager.

getOnlineUserList

public DistributedList getOnlineUserList()
Returns the distributed list of users, that are currently online.
Returns:
DistributedList containing User objects.

inviteUser

public void inviteUser(java.lang.String username,
                       User byUser,
                       Table table,
                       int direction)
                throws UserUnavailableException
Invite an user to a table.
Parameters:
username - login name of the user to invite.
table - table the user is invited to
direction - Direction the user is invited in.
Throws:
UserUnavailableException - if the user is not available.

getUser

public UserImpl getUser(java.lang.String username)
Returns the foyer listener of an user.
Parameters:
username - Name of the user.
Returns:
the listener of the user, null if not available.

isUserPlaying

public boolean isUserPlaying(User user)
Returns if a user is currently playing at a table or in a tournament.
Parameters:
username - name of the user.
Returns:
true if user is currently playing.

addPlayingUser

public void addPlayingUser(UserImpl user)
                    throws UserAlreadyPlayingException
Add a user to the list of currently playing users.
Parameters:
user - User to add.
Throws:
UserAlreadyPlayingException - If the user is already playing

removePlayingUser

public void removePlayingUser(UserImpl user)
Remove a user from the list of currently playing users.
Parameters:
user - User to remove