Class ActiveSessionProvider

java.lang.Object
de.murmelmeister.murmelapi.logging.ActiveSessionProvider
All Implemented Interfaces:
ActiveSession

public final class ActiveSessionProvider extends Object implements ActiveSession
  • Constructor Details

    • ActiveSessionProvider

      public ActiveSessionProvider(Database database)
  • Method Details

    • setup

      public static void setup(Database database)
    • existsSession

      public boolean existsSession(int userId)
      Description copied from interface: ActiveSession
      Checks whether a session exists for the specified user ID.
      Specified by:
      existsSession in interface ActiveSession
      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

      public void startSession(int userId, InetAddress inetAddress, String clientVersion, String protocolVersion)
      Description copied from interface: ActiveSession
      Creates a new session for the specified user with the provided details.
      Specified by:
      startSession in interface ActiveSession
      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

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

      public UUID getSessionId(int userId)
      Description copied from interface: ActiveSession
      Retrieves the session ID associated with the specified user.
      Specified by:
      getSessionId in interface ActiveSession
      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

      public String getIpAddress(int userId)
      Description copied from interface: ActiveSession
      Retrieves the current IP address associated with a specific user.
      Specified by:
      getIpAddress in interface ActiveSession
      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

      public Timestamp getLoginTime(int userId)
      Description copied from interface: ActiveSession
      Retrieves the timestamp of the user's login time for the active session.
      Specified by:
      getLoginTime in interface ActiveSession
      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

      public String getClientVersion(int userId)
      Description copied from interface: ActiveSession
      Retrieves the client version associated with the specified user ID.
      Specified by:
      getClientVersion in interface ActiveSession
      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

      public String getProtocolVersion(int userId)
      Description copied from interface: ActiveSession
      Retrieves the protocol version associated with a specific user based on their user ID.
      Specified by:
      getProtocolVersion in interface ActiveSession
      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

      public boolean isOnline(int userId)
      Description copied from interface: ActiveSession
      Checks if the user with the specified user ID is currently online.
      Specified by:
      isOnline in interface ActiveSession
      Parameters:
      userId - The unique identifier of the user to check.
      Returns:
      true if the user is online, false otherwise.