Interface ActiveSession

All Known Implementing Classes:
ActiveSessionProvider

public sealed interface ActiveSession permits ActiveSessionProvider
Represents a collection of active sessions for users.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    closeSession(int userId)
    Closes the active session associated with the specified user ID.
    boolean
    existsSession(int userId)
    Checks whether a session exists for the specified user ID.
    getClientVersion(int userId)
    Retrieves the client version associated with the specified user ID.
    getIpAddress(int userId)
    Retrieves the current IP address associated with a specific user.
    getLoginTime(int userId)
    Retrieves the timestamp of the user's login time for the active session.
    getProtocolVersion(int userId)
    Retrieves the protocol version associated with a specific user based on their user ID.
    getSessionId(int userId)
    Retrieves the session ID associated with the specified user.
    boolean
    isOnline(int userId)
    Checks if the user with the specified user ID is currently online.
    void
    startSession(int userId, InetAddress inetAddress, String clientVersion, String protocolVersion)
    Creates a new session for the specified user with the provided details.
  • Method Details

    • existsSession

      boolean existsSession(int userId)
      Checks whether a session exists for the specified user ID.
      Parameters:
      userId - The unique identifier of the user whose session existence is to be checked.
      Returns:
      true if a session exists for the specified user ID, false otherwise.
    • startSession

      void startSession(int userId, InetAddress inetAddress, String clientVersion, String protocolVersion)
      Creates a new session for the specified user with the provided details.
      Parameters:
      userId - The unique identifier of the user for whom the session is being created.
      inetAddress - The IP address of the user's device initiating the session.
      clientVersion - The version of the client used by the user.
      protocolVersion - The protocol version used by the client to communicate.
    • closeSession

      void closeSession(int userId)
      Closes the active session associated with the specified user ID. And create a new login entry in the login history.
      Parameters:
      userId - The unique identifier of the user whose session is to be closed.
    • getSessionId

      UUID getSessionId(int userId)
      Retrieves the session ID associated with the specified user.
      Parameters:
      userId - The unique identifier of the user whose session ID is to be retrieved.
      Returns:
      The UUID representing the session ID for the specified user, or null if no session exists.
    • getIpAddress

      String getIpAddress(int userId)
      Retrieves the current IP address associated with a specific user.
      Parameters:
      userId - The unique identifier of the user whose current IP address is being retrieved.
      Returns:
      The current IP address as a String for the specified user, or null if no IP address is found.
    • getLoginTime

      Timestamp getLoginTime(int userId)
      Retrieves the timestamp of the user's login time for the active session.
      Parameters:
      userId - The unique identifier of the user whose login time is to be retrieved.
      Returns:
      A Timestamp object representing the user's login time, or null if no active session exists for the specified user.
    • getClientVersion

      String getClientVersion(int userId)
      Retrieves the client version associated with the specified user ID.
      Parameters:
      userId - The unique identifier of the user whose client version is to be retrieved.
      Returns:
      The client version as a string, or null if no client version is associated with the given user ID.
    • getProtocolVersion

      String getProtocolVersion(int userId)
      Retrieves the protocol version associated with a specific user based on their user ID.
      Parameters:
      userId - The unique identifier of the user.
      Returns:
      The protocol version as a string, or null if no protocol version is associated with the user.
    • isOnline

      boolean isOnline(int userId)
      Checks if the user with the specified user ID is currently online.
      Parameters:
      userId - The unique identifier of the user to check.
      Returns:
      true if the user is online, false otherwise.