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 Summary
Modifier and TypeMethodDescriptionadd(SessionContext sessionContext) Adds to session management.voidBroadcasts a message to all users.intCurrent number of online usersbooleanexistUserSession(long userId) true if user existsdefault voidgetUserSession(long userId) Gets UserSession.getUserSession(SessionContext sessionContext) Gets UserSession.getUserSessionByUserChannelId(long userChannelId) getUserSessiondefault voiddefault voidIf a UserSession is present, performs the given action with it, otherwise does nothing.default voidifPresent(Collection<Long> userIdList, Consumer<Session> consumer) If a UserSession is present, performs the given action with it, otherwise does nothing.voidremoveUserSession(long userId, Object msg) Removes UserSession by userId, and sends a message before removal.voidremoveUserSession(Session 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 interface AttrOptionDynamic
getOptions, ifNull, ifPresent, option, option, optionValue
-
Method Details
-
add
Adds to session management.- Parameters:
sessionContext- sessionContext
-
getUserSession
Gets UserSession.- Parameters:
sessionContext- sessionContext- Returns:
- SessionContext
-
getUserSession
Gets UserSession.- Parameters:
userId- userId- Returns:
- UserSession
-
getUserSessionByUserChannelId
getUserSession- Parameters:
userChannelId- userChannelId- Returns:
- userSession
-
ifPresent
-
ifPresent
If a UserSession is present, performs the given action with it, otherwise does nothing.- Parameters:
userIdList- userIdList cannot be nullconsumer- The action to be performed if the UserSession is present
-
ifPresent
-
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- userChannelIduserId- userId- Returns:
- true if set successfully
-
removeUserSession
Removes UserSession.- Parameters:
userSession- userSession
-
removeUserSession
Removes UserSession by userId, and sends a message before removal.- Parameters:
userId- userIdmsg- msg
-
setUserHook
-
getUserHook
UserHook getUserHook() -
countOnline
int countOnline()Current number of online users- Returns:
- Current number of online users
-
broadcast
-
forEach
-
listUserSession
-
setJoinEnum
-