im问题修复-获取不到用户
This commit is contained in:
parent
1754272f7f
commit
e97416feeb
@ -146,11 +146,12 @@ public class DistributedSessionService {
|
||||
*/
|
||||
public List<Integer> getOnlineUserIds() {
|
||||
// 方法1: 通过服务器用户集合获取(推荐)
|
||||
String serverUsersKey = SERVER_USERS_KEY + new RabbitMQManager().getServerId();
|
||||
String serverUsersKey = SERVER_USERS_KEY + getServerId();
|
||||
Set<Object> userIds = redisTemplate.opsForSet().members(serverUsersKey);
|
||||
|
||||
if (userIds != null && !userIds.isEmpty()) {
|
||||
return userIds.stream()
|
||||
List<Integer> userIdList = new ArrayList<>(userIds.size());
|
||||
userIdList= userIds.stream()
|
||||
.map(userIdStr -> {
|
||||
try {
|
||||
return Integer.parseInt(userIdStr.toString());
|
||||
@ -160,6 +161,7 @@ public class DistributedSessionService {
|
||||
})
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toList());
|
||||
return userIdList;
|
||||
}
|
||||
|
||||
return new ArrayList<>();
|
||||
|
||||
@ -68,7 +68,7 @@ public class MallsuiteImSocketHandler implements WebSocketHandler {
|
||||
distributedSessionService.registerUserSession(loginUserId, sessionId, attributes);
|
||||
|
||||
// 处理离线消息等原有逻辑...
|
||||
this.updateOnlineStatus();
|
||||
// this.updateOnlineStatus();
|
||||
|
||||
}
|
||||
|
||||
@ -214,7 +214,7 @@ public class MallsuiteImSocketHandler implements WebSocketHandler {
|
||||
distributedSessionService.removeUserFromGroup(groupId, sessionId);
|
||||
}
|
||||
|
||||
this.updateOnlineStatus();
|
||||
// this.updateOnlineStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Loading…
Reference in New Issue
Block a user