Class SocketUserSessions

java.lang.Object
com.iohao.net.external.core.netty.session.SocketUserSessions
All Implemented Interfaces:
AttrOptionDynamic, UserSessions<io.netty.channel.ChannelHandlerContext, SocketUserSession>

public final class SocketUserSessions extends Object
Session managers for TCP and WebSocket
Author:
渔民小镇
date:
2023-02-18
  • Constructor Details

    • SocketUserSessions

      public SocketUserSessions()
  • Method Details

    • add

      public SocketUserSession add(io.netty.channel.ChannelHandlerContext channelHandlerContext)
      Description copied from interface: UserSessions
      Adds to session management.
      Parameters:
      channelHandlerContext - sessionContext
    • getUserSession

      public SocketUserSession getUserSession(io.netty.channel.ChannelHandlerContext channelHandlerContext)
      Description copied from interface: UserSessions
      Gets UserSession.
      Parameters:
      channelHandlerContext - sessionContext
      Returns:
      SessionContext
    • settingUserId

      public boolean settingUserId(long userChannelId, long userId)
      Description copied from interface: UserSessions
      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

      public void removeUserSession(SocketUserSession userSession)
      Description copied from interface: UserSessions
      Removes UserSession.
      Parameters:
      userSession - userSession
    • countOnline

      public int countOnline()
      Description copied from interface: UserSessions
      Current number of online users
      Returns:
      Current number of online users
    • broadcast

      public void broadcast(Object msg)
      Description copied from interface: UserSessions
      Broadcasts a message to all users.
      Parameters:
      msg - message
    • setJoinEnum

      public void setJoinEnum(ExternalJoinEnum joinEnum)
      Description copied from interface: UserSessions
      Connection method
      Specified by:
      setJoinEnum in interface UserSessions<ChannelHandlerContext, Session extends UserSession>
      Parameters:
      joinEnum - joinEnum
    • setUserHook

      public void setUserHook(UserHook userHook)
      Description copied from interface: UserSessions
      userHook
      Specified by:
      setUserHook in interface UserSessions<ChannelHandlerContext, Session extends UserSession>
      Parameters:
      userHook - userHook
    • getUserHook

      public UserHook getUserHook()
      Specified by:
      getUserHook in interface UserSessions<ChannelHandlerContext, Session extends UserSession>
    • existUserSession

      public boolean existUserSession(long userId)
      Description copied from interface: UserSessions
      true if user exists
      Specified by:
      existUserSession in interface UserSessions<ChannelHandlerContext, Session extends UserSession>
      Parameters:
      userId - user id
      Returns:
      true if user exists
    • getUserSession

      public SocketUserSession getUserSession(long userId)
      Description copied from interface: UserSessions
      Gets UserSession.
      Specified by:
      getUserSession in interface UserSessions<ChannelHandlerContext, Session extends UserSession>
      Parameters:
      userId - userId
      Returns:
      UserSession
    • getUserSessionByUserChannelId

      public SocketUserSession getUserSessionByUserChannelId(long userChannelId)
      Description copied from interface: UserSessions
      getUserSession
      Specified by:
      getUserSessionByUserChannelId in interface UserSessions<ChannelHandlerContext, Session extends UserSession>
      Parameters:
      userChannelId - userChannelId
      Returns:
      userSession
    • removeUserSession

      public void removeUserSession(long userId, Object msg)
      Description copied from interface: UserSessions
      Removes UserSession by userId, and sends a message before removal.
      Specified by:
      removeUserSession in interface UserSessions<ChannelHandlerContext, Session extends UserSession>
      Parameters:
      userId - userId
      msg - msg
    • listUserSession

      public List<SocketUserSession> listUserSession()
      Specified by:
      listUserSession in interface UserSessions<ChannelHandlerContext, Session extends UserSession>