Interface UserSessions<SessionContext, Session extends UserSession>

All Superinterfaces:
AttrOptionDynamic
All Known Implementing Classes:
SocketUserSessions

public interface UserSessions<SessionContext, Session extends UserSession> extends AttrOptionDynamic
UserSession manager
Author:
渔民小镇
date:
2023-02-18
  • Method Details

    • add

      Session add(SessionContext sessionContext)
      Adds to session management.
      Parameters:
      sessionContext - sessionContext
    • getUserSession

      Session getUserSession(SessionContext sessionContext)
      Gets UserSession.
      Parameters:
      sessionContext - sessionContext
      Returns:
      SessionContext
    • getUserSession

      Session getUserSession(long userId)
      Gets UserSession.
      Parameters:
      userId - userId
      Returns:
      UserSession
    • getUserSessionByUserChannelId

      Session getUserSessionByUserChannelId(long userChannelId)
      getUserSession
      Parameters:
      userChannelId - userChannelId
      Returns:
      userSession
    • ifPresent

      default void ifPresent(long userId, Consumer<Session> consumer)
      If a UserSession is present, performs the given action with it, otherwise does nothing.
      Parameters:
      userId - userId
      consumer - The action to be performed if the UserSession is present
    • ifPresent

      default void ifPresent(Collection<Long> userIdList, Consumer<Session> consumer)
      If a UserSession is present, performs the given action with it, otherwise does nothing.
      Parameters:
      userIdList - userIdList cannot be null
      consumer - The action to be performed if the UserSession is present
    • ifPresent

      default void ifPresent(long[] userIdList, Consumer<Session> consumer)
    • existUserSession

      boolean existUserSession(long userId)
      true if user exists
      Parameters:
      userId - user id
      Returns:
      true if user exists
    • settingUserId

      boolean settingUserId(long userChannelId, long userId)
      Sets the userId for the channel, indicating that the identity has been authenticated (i.e., logged in).
      Parameters:
      userChannelId - userChannelId
      userId - userId
      Returns:
      true if set successfully
    • removeUserSession

      void removeUserSession(Session userSession)
      Removes UserSession.
      Parameters:
      userSession - userSession
    • removeUserSession

      void removeUserSession(long userId, Object msg)
      Removes UserSession by userId, and sends a message before removal.
      Parameters:
      userId - userId
      msg - msg
    • setUserHook

      void setUserHook(UserHook userHook)
      userHook
      Parameters:
      userHook - userHook
    • getUserHook

      UserHook getUserHook()
    • countOnline

      int countOnline()
      Current number of online users
      Returns:
      Current number of online users
    • broadcast

      void broadcast(Object msg)
      Broadcasts a message to all users.
      Parameters:
      msg - message
    • forEach

      default void forEach(Consumer<Session> consumer)
    • listUserSession

      List<Session> listUserSession()
    • setJoinEnum

      void setJoinEnum(ExternalJoinEnum joinEnum)
      Connection method
      Parameters:
      joinEnum - joinEnum