im调整sesion,解决一次性清除session问题
This commit is contained in:
parent
47331a5b2a
commit
3971c5f504
@ -41,9 +41,9 @@ public class LocalSessionManager {
|
||||
if (userId == null || session == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
userSessions.computeIfPresent(userId, (key, sessions) -> {
|
||||
sessions.remove(session);
|
||||
sessions.removeIf(webSocketSession ->
|
||||
webSocketSession.getId().equals(session.getId()));
|
||||
return sessions.isEmpty() ? null : sessions;
|
||||
});
|
||||
}
|
||||
@ -112,13 +112,11 @@ public class LocalSessionManager {
|
||||
* 移除群组会话
|
||||
*/
|
||||
public void removeGroupSession(String groupId, WebSocketSession session) {
|
||||
List<WebSocketSession> sessions = groupSessions.get(groupId);
|
||||
if (sessions != null) {
|
||||
sessions.remove(session);
|
||||
if (sessions.isEmpty()) {
|
||||
groupSessions.remove(groupId);
|
||||
}
|
||||
}
|
||||
groupSessions.computeIfPresent(groupId, (key, gropSession) -> {
|
||||
gropSession.removeIf(webSocketSession ->
|
||||
webSocketSession.getId().equals(session.getId()));
|
||||
return gropSession.isEmpty() ? null : gropSession;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user