org.jdesktop.wonderland.server
Class UserManager

java.lang.Object
  extended by org.jdesktop.wonderland.server.UserManager
All Implemented Interfaces:
com.sun.sgs.app.ManagedObject, java.io.Serializable

public class UserManager
extends java.lang.Object
implements com.sun.sgs.app.ManagedObject, java.io.Serializable

Manages the entire set of users logged into the system.

Author:
paulby
See Also:
Serialized Form

Method Summary
 void addUserListener(UserListener listener)
          Add a listener to the set of listeners which are notified when any user logs out.
 void finishLogout(WonderlandClientID clientID)
          Finish the logout for the current session.
 java.util.Collection<com.sun.sgs.app.ManagedReference<UserMO>> getAllUsers()
          Return a Collection of all users currently logged in
 UserMO getUser(WonderlandClientID clientID)
          Return the user with the given userID
 int getUserCount()
          Return total number of users currently logged in
 int getUserLimit()
          Get the maximum number of users allowed on the server
static UserManager getUserManager()
          Return singleton user manager
static UserMO getUserMO(java.lang.String username)
          Return the UserMO object associated with the unique userName
 boolean isLoggedIn(java.lang.String userName)
          Returns true if the user with the specified userName is currently logged in, false otherwise.
 void login(WonderlandClientID clientID)
          Log the user in from the specificed session.
 void removeUserListener(UserListener listener)
          Removed a user listener that is listening to all users.
 void setUserLimit(int userLimit)
          Set the maximum number of users allowed on the server
 java.util.Queue<com.sun.sgs.app.Task> startLogout(WonderlandClientID clientID)
          Start the logout process for the given session.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getUserManager

public static UserManager getUserManager()
Return singleton user manager

Returns:
the user manager

getUser

public UserMO getUser(WonderlandClientID clientID)
Return the user with the given userID

Returns:
reference to the UserGLO

getUserMO

public static UserMO getUserMO(java.lang.String username)
Return the UserMO object associated with the unique userName

Returns:
UserMO object for username, or null if no such user

isLoggedIn

public boolean isLoggedIn(java.lang.String userName)
Returns true if the user with the specified userName is currently logged in, false otherwise.


getAllUsers

public java.util.Collection<com.sun.sgs.app.ManagedReference<UserMO>> getAllUsers()
Return a Collection of all users currently logged in

Returns:
collection of ManagedReferences to UserGLO's

login

public void login(WonderlandClientID clientID)
Log the user in from the specificed session.

Parameters:
session -

startLogout

public java.util.Queue<com.sun.sgs.app.Task> startLogout(WonderlandClientID clientID)
Start the logout process for the given session. This will create a queue of tasks associated with the given session, that are executed sequentially. Once this queue is empty, all mappings from the given id to a UserMO will be removed.

Parameters:
clientID - the id of the client to begin the logout process for
Returns:
the queue of tasks to perform before logout.
Throws:
java.lang.IllegalArgumentException - if the given clientID is not currently logged in.

finishLogout

public void finishLogout(WonderlandClientID clientID)
Finish the logout for the current session. This method will first notify any user listeners of the fact that the user is logging out. It will then run all logout tasks for the given user. When the logout tasks have all completed, all mappings between the client id and the UserMO will be removed.

Parameters:
clientID - the id of the client to end the logout process for
Throws:
java.lang.IllegalArgumentException - if no user is associated with the given client id.

getUserCount

public int getUserCount()
Return total number of users currently logged in

Returns:
total number of users currently logged in

getUserLimit

public int getUserLimit()
Get the maximum number of users allowed on the server

Returns:
the maximum number of concurrent users this world will allow to log in.

setUserLimit

public void setUserLimit(int userLimit)
Set the maximum number of users allowed on the server

Parameters:
userLimit - the maximum number of concurrent users this world will allow to log in.

addUserListener

public void addUserListener(UserListener listener)
Add a listener to the set of listeners which are notified when any user logs out. In most cases, you should use add a listener to a specific UserMO instead.

Parameters:
listener - the listener to remove

removeUserListener

public void removeUserListener(UserListener listener)
Removed a user listener that is listening to all users.

Parameters:
listener - the listener to remove


Open Wonderland - http://openwonderland.org