de.esprit.netsuite.server.netch

## Class SessionManager

- java.lang.Object
- - de.esprit.common.util.DumpableObject
  - - de.esprit.appsuite.launch.AbstractApplicationObject<S>
    - - de.esprit.netsuite.server.AbstractServerObject<ServerContext>
      - - de.esprit.netsuite.server.netch.SessionManager

- All Implemented Interfaces:
    ApplicationObject<ServerContext>, SimpleLogSupport, Dumpable, PermissionControlled, ServerObject<ServerContext>

      public final class SessionManager
      extends AbstractServerObject<ServerContext>
      implements PermissionControlled

  This is a synchronized List containing the currently connected clients.
  Author:
    Rainer Buesch

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static PermissionDefinition` | `permissionDef`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SessionManager(ServerContext serverCtx)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addSession(Session session)`
    `void` | `closeAllSessions()` Closes all sessions without notification to the clients
    `void` | `closeSession(SessionId sessionId)`
    `ServerNetworkAdapter` | `fetchNetworkAdapterFor(SessionId sessionId)`
    `Session` | `fetchSessionBySessionId(SessionId sessId)`
    `Session` | `findSessionBySessionId(SessionId sessId)`
    `SessionId` | `findSessionIdBySID(int sid)`
    `java.util.List<SessionId>` | `findSessionIdsByUserName(java.lang.String userName)`
    `java.util.List<SessionId>` | `findSessionsIdsByUserId(UserId userId)`
    `java.util.List<CoSessionId>` | `getCoClientSessionIds()` Returns the session contexts of co-clients only
    `int` | `getLoginCount()` Counts the number of users currently logged in
    `int` | `getLoginCount(UserId userId)` Counts how often the given user is logged in
    `ServerMessageDispatcher` | `getMessageDispatcher()`
    `java.util.List<UserId>` | `getOnlineUserIds()` Returns the `UserId`s of all logged in users.
    `PermissionDefinition` | `getPermissionDefinition()` Returns an object that identifies a `PermissionControlled` object with a unique name and provides a list of supported assignable permissions.
    `Session` | `getSession(int i)`
    `int` | `getSessionCount()`
    `java.util.List<SessionId>` | `getSessionIds()` Returns the SessionIds of all sessions including co-clients
    `java.util.List<SessionId>` | `getSessionIds(boolean isIncludeCoClients)` Returns the session contexts of normal clients (no co-clients)
    `static boolean` | `isMessageDeliverable(Session session, NetMessage msg)`
    `boolean` | `isUserLoggedIn(java.lang.String userName)`
    `boolean` | `isUserLoggedIn(User user)`
    `void` | `loginUser(SessionId sessionId, User user)`
    `void` | `logoutAllUsers()`
    `void` | `logoutUser(SessionId sessId)`
    `void` | `sendNetMessage(NetMessage msg)`
    `void` | `setMessageDispatcher(ServerMessageDispatcher dispatcher)`
    `SessionId` | `setUserIdForSession(SessionId sessId, UserId userId)`
    `void` | `updateUserSessions(UserId userId)`

    - ### Methods inherited from class de.esprit.netsuite.server.AbstractServerObject

      `checkPermission, getServerConfig, getServerContext, getStatisticManager, toString`

    - ### Methods inherited from class de.esprit.appsuite.launch.AbstractApplicationObject

      `getApplicationContext, getLogChannel, isLogDebug, isLogVerbose, logDebug, logDump, logError, logError, logFatal, logInfo, logVerbose, logWarning, setLogChannel`

    - ### Methods inherited from class de.esprit.common.util.DumpableObject

      `configureDumpHeadlineLength, configureDumpMaxElementsPrinted, copyDumpStringValues, copyToStringValues, createDumpHeader, toDumpString, toDumpString, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### permissionDef

          public static final PermissionDefinition permissionDef

  - ### Constructor Detail

    - #### SessionManager

          public SessionManager(ServerContext serverCtx)

  - ### Method Detail

    - #### getPermissionDefinition

          public final PermissionDefinition getPermissionDefinition()

      Description copied from interface: `PermissionControlled`
      Returns an object that identifies a `PermissionControlled` object with a unique name and provides a list of supported assignable permissions.
      Specified by:
        `getPermissionDefinition` in interface `PermissionControlled`

    - #### setMessageDispatcher

          public void setMessageDispatcher(ServerMessageDispatcher dispatcher)

    - #### getMessageDispatcher

          public ServerMessageDispatcher getMessageDispatcher()

    - #### addSession

          public void addSession(Session session)

    - #### loginUser

          public void loginUser(SessionId sessionId,
                       User user)
                         throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### logoutUser

          public void logoutUser(SessionId sessId)
                          throws SessionNotFoundException

      Throws:
        `SessionNotFoundException`

    - #### getOnlineUserIds

          public java.util.List<UserId> getOnlineUserIds()

      Returns the `UserId`s of all logged in users. Even if a users is logged in multiple times it will appear only once in the list.

    - #### closeSession

          public void closeSession(SessionId sessionId)

    - #### getSession

          public Session getSession(int i)

    - #### setUserIdForSession

          public SessionId setUserIdForSession(SessionId sessId,
                                      UserId userId)
                                        throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### fetchSessionBySessionId

          public Session fetchSessionBySessionId(SessionId sessId)
                                          throws SessionNotFoundException

      Throws:
        `SessionNotFoundException`

    - #### fetchNetworkAdapterFor

          public ServerNetworkAdapter fetchNetworkAdapterFor(SessionId sessionId)
                                                      throws SessionNotFoundException

      Throws:
        `SessionNotFoundException`

    - #### findSessionBySessionId

          public Session findSessionBySessionId(SessionId sessId)

    - #### findSessionIdBySID

          public SessionId findSessionIdBySID(int sid)

    - #### findSessionIdsByUserName

          public java.util.List<SessionId> findSessionIdsByUserName(java.lang.String userName)

    - #### findSessionsIdsByUserId

          public java.util.List<SessionId> findSessionsIdsByUserId(UserId userId)

    - #### isUserLoggedIn

          public final boolean isUserLoggedIn(User user)

    - #### isUserLoggedIn

          public final boolean isUserLoggedIn(java.lang.String userName)

    - #### getSessionIds

          public final java.util.List<SessionId> getSessionIds()

      Returns the SessionIds of all sessions including co-clients

    - #### getSessionIds

          public final java.util.List<SessionId> getSessionIds(boolean isIncludeCoClients)

      Returns the session contexts of normal clients (no co-clients)

    - #### getCoClientSessionIds

          public final java.util.List<CoSessionId> getCoClientSessionIds()

      Returns the session contexts of co-clients only

    - #### sendNetMessage

          public final void sendNetMessage(NetMessage msg)

    - #### isMessageDeliverable

          public static boolean isMessageDeliverable(Session session,
                                     NetMessage msg)

    - #### getSessionCount

          public int getSessionCount()

    - #### updateUserSessions

          public void updateUserSessions(UserId userId)

    - #### getLoginCount

          public int getLoginCount()

      Counts the number of users currently logged in

    - #### getLoginCount

          public int getLoginCount(UserId userId)

      Counts how often the given user is logged in

    - #### logoutAllUsers

          public void logoutAllUsers()

    - #### closeAllSessions

          public void closeAllSessions()

      Closes all sessions without notification to the clients

Copyright © 2014 EsprIT-Systems. All Rights Reserved.