private UserSessionsInfo getUserSessions(Long userId) {
        UserSessionsManager manager = userIdToSessionsManager.get(userId);
        if (manager == null) {
            return new UserSessionsInfo(userId, UserStatus.OFFLINE, Collections.emptyList());
        }
        Collection<UserSession> sessions = manager.getDeviceTypeToSession()
                .values();
        int size = sessions.size();
        if (size == 0) {
            return new UserSessionsInfo(userId, UserStatus.OFFLINE, Collections.emptyList());
        }
        ArrayList<UserSessionInfo> sessionInfos = new ArrayList<>(size);
        for (UserSession session : sessions) {
            ByteArrayWrapper ip = session.getIp();
            sessionInfos.add(new UserSessionInfo(
                    session.getId(),
                    session.getVersion(),
                    session.getDeviceType(),
                    session.getDeviceDetails(),
                    session.getLoginDate(),
                    session.getLoginLocation(),
                    new Date(session.getLastHeartbeatRequestTimestampMillis()),
                    new Date(session.getLastRequestTimestampMillis()),
                    session.isSessionOpen(),
                    ip == null
                            ? null
                            : ip.getBytes(),
                    null));
        }
        return new UserSessionsInfo(userId, manager.getUserStatus(), sessionInfos);
    }
@return closed session count
@implNote The method will be called definitely when a session is closed no matter it is
          closed by the client or the server, and the method will clean up sessions in both
          local and Redis.
turms-gateway/src/main/java/im/turms/gateway/domain/session/service/SessionService.java