Class SocketUserSessions
java.lang.Object
com.iohao.net.external.core.netty.session.SocketUserSessions
- All Implemented Interfaces:
AttrOptionDynamic, UserSessions<io.netty.channel.ChannelHandlerContext, SocketUserSession>
Session managers for TCP and WebSocket
- Author:
- 渔民小镇
- date:
- 2023-02-18
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd(io.netty.channel.ChannelHandlerContext channelHandlerContext) Adds to session management.voidBroadcasts a message to all users.intCurrent number of online usersbooleanexistUserSession(long userId) true if user existsgetUserSession(long userId) Gets UserSession.getUserSession(io.netty.channel.ChannelHandlerContext channelHandlerContext) Gets UserSession.getUserSessionByUserChannelId(long userChannelId) getUserSessionvoidremoveUserSession(long userId, Object msg) Removes UserSession by userId, and sends a message before removal.voidremoveUserSession(SocketUserSession userSession) Removes UserSession.voidsetJoinEnum(ExternalJoinEnum joinEnum) Connection methodbooleansettingUserId(long userChannelId, long userId) Sets the userId for the channel, indicating that the identity has been authenticated (i.e., logged in).voidsetUserHook(UserHook userHook) userHookMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface AttrOptionDynamic
getOptions, ifNull, ifPresent, option, option, optionValueMethods inherited from interface UserSessions
forEach, ifPresent, ifPresent, ifPresent
-
Constructor Details
-
SocketUserSessions
public SocketUserSessions()
-
-
Method Details
-
add
Description copied from interface:UserSessionsAdds to session management.- Parameters:
channelHandlerContext- sessionContext
-
getUserSession
public SocketUserSession getUserSession(io.netty.channel.ChannelHandlerContext channelHandlerContext) Description copied from interface:UserSessionsGets UserSession.- Parameters:
channelHandlerContext- sessionContext- Returns:
- SessionContext
-
settingUserId
public boolean settingUserId(long userChannelId, long userId) Description copied from interface:UserSessionsSets the userId for the channel, indicating that the identity has been authenticated (i.e., logged in).- Parameters:
userChannelId- userChannelIduserId- userId- Returns:
- true if set successfully
-
removeUserSession
Description copied from interface:UserSessionsRemoves UserSession.- Parameters:
userSession- userSession
-
countOnline
public int countOnline()Description copied from interface:UserSessionsCurrent number of online users- Returns:
- Current number of online users
-
broadcast
Description copied from interface:UserSessionsBroadcasts a message to all users.- Parameters:
msg- message
-
setJoinEnum
Description copied from interface:UserSessionsConnection method- Specified by:
setJoinEnumin interfaceUserSessions<ChannelHandlerContext, Session extends UserSession>- Parameters:
joinEnum- joinEnum
-
setUserHook
Description copied from interface:UserSessionsuserHook- Specified by:
setUserHookin interfaceUserSessions<ChannelHandlerContext, Session extends UserSession>- Parameters:
userHook- userHook
-
getUserHook
- Specified by:
getUserHookin interfaceUserSessions<ChannelHandlerContext, Session extends UserSession>
-
existUserSession
public boolean existUserSession(long userId) Description copied from interface:UserSessionstrue if user exists- Specified by:
existUserSessionin interfaceUserSessions<ChannelHandlerContext, Session extends UserSession>- Parameters:
userId- user id- Returns:
- true if user exists
-
getUserSession
Description copied from interface:UserSessionsGets UserSession.- Specified by:
getUserSessionin interfaceUserSessions<ChannelHandlerContext, Session extends UserSession>- Parameters:
userId- userId- Returns:
- UserSession
-
getUserSessionByUserChannelId
Description copied from interface:UserSessionsgetUserSession- Specified by:
getUserSessionByUserChannelIdin interfaceUserSessions<ChannelHandlerContext, Session extends UserSession>- Parameters:
userChannelId- userChannelId- Returns:
- userSession
-
removeUserSession
Description copied from interface:UserSessionsRemoves UserSession by userId, and sends a message before removal.- Specified by:
removeUserSessionin interfaceUserSessions<ChannelHandlerContext, Session extends UserSession>- Parameters:
userId- userIdmsg- msg
-
listUserSession
- Specified by:
listUserSessionin interfaceUserSessions<ChannelHandlerContext, Session extends UserSession>
-