Server
Class DB
java.lang.Object
|
+--Server.DB
- public final class DB
- extends java.lang.Object
A database for holding users, session and the connection between them.
The database is synchronized where appropriate, and is safe for multi-threading.
Field Summary |
private static java.util.Map |
sessionByName
A matching between Names (e.g: strings) and their session. |
private static java.util.Map |
sessionByUser
A matching between users (e.g: an IP Address) and their session. |
Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait |
sessionByUser
private static java.util.Map sessionByUser
- A matching between users (e.g: an IP Address) and their session.
sessionByName
private static java.util.Map sessionByName
- A matching between Names (e.g: strings) and their session.
DB
public DB()
getSessionByName
public static final Session getSessionByName(java.lang.String sessionName)
- Retrieve a session by its name
- Parameters:
sessionName
- The name of the session to retrieve- Returns:
- The session associated with the given name
addSession
public static final void addSession(Session s)
- Add a given session to the database
- Parameters:
s
- The session to add
getSessionByUser
public static final Session getSessionByUser(User user)
- Get a session by a given user
- Parameters:
user
- A user- Returns:
- The associated session
removeSession
public static final void removeSession(Session s)
- Remove a given session from the database
- Parameters:
s
- The session to remove
addUser
public static final void addUser(User user,
Session session)
- Add a given user to a given session.
The method assumes the session is a valid registered session instance.
- Parameters:
user
- The user to addsession
- The session to add to
removeUser
public static final void removeUser(User user,
Session session)
- Remove a user from a given session.
- Parameters:
user
- The use to removesession
- The session to remove the user from