class SessionsDB extends Object
SessionRecords.
Provides synchronized access for concurrent SAM handlers.| Modifier and Type | Class and Description |
|---|---|
(package private) static class | SessionsDB.ExistingDestExceptionException thrown when attempting to create a session with an existing destination. |
(package private) static class | SessionsDB.ExistingIdExceptionException thrown when attempting to create a session with an existing ID. |
| Constructor and Description |
|---|
SessionsDB()Create a new empty sessions database. |
| Modifier and Type | Method and Description |
|---|---|
boolean | containsKey(String nick)Check if a session with the given nickname exists. |
boolean | del(String nick)Remove a session record by nickname. |
SessionRecord | get(String nick)Get a session record by nickname. |
Map<String,SessionRecord> | getAllEntries()Return a snapshot of all entries (nick -> SessionRecord). |
void | put(String nick,
SessionRecord session)Store a session record. |
void | putDupDestOK(String nick,
SessionRecord session)Store a session record, allowing duplicate destinations. |
int | removeStale(long maxAgeMs)Remove sessions that have not been accessed for longer than maxAgeMs. |
int | size()Get the number of registered sessions. |
public boolean containsKey(String nick)
nick - the session nicknamepublic boolean del(String nick)
nick - the session nicknamepublic SessionRecord get(String nick)
nick - the session nicknamepublic Map<String,SessionRecord> getAllEntries()
public void put(String nick, SessionRecord session) throws SessionsDB.ExistingIdException, SessionsDB.ExistingDestException
nick - the session nicknamesession - the sessionSessionsDB.ExistingIdException - if a session with this nick already existsSessionsDB.ExistingDestException - if a session with this destination already existspublic void putDupDestOK(String nick, SessionRecord session) throws SessionsDB.ExistingIdException
nick - the session nicknamesession - the sessionSessionsDB.ExistingIdException - if a session with this nick already existspublic int removeStale(long maxAgeMs)
maxAgeMs - maximum age in milliseconds since last accesspublic int size()