Hello everybody,
thank you for this open source openvidu server, really a great job.
I am trying to understand this part of the code
openvidu-java-client → OpenVidu.java → fetch()
How can i make the difference between active session , closed session und dead sessions?
his.activeSessions.computeIfPresent(sessionId, (sId, s) → {
String beforeJSON = s.toJson();
s = s.resetSessionWithJson((JSONObject) session);
String afterJSON = s.toJson();
boolean changed = !beforeJSON.equals(afterJSON);
hasChanged[0] = hasChanged[0] || changed;
log.info(“Available session ‘{}’ info fetched. Any change: {}”, sessionId, changed);
return s;
});
this.activeSessions.computeIfAbsent(sessionId, sId → {
log.info(“New session ‘{}’ fetched”, sessionId);
hasChanged[0] = true;
return new Session(this, (JSONObject) session);
});
});
// Remove closed sessions from activeSessions map
this.activeSessions = this.activeSessions.entrySet().stream().filter(entry → {
if (fetchedSessionIds.contains(entry.getKey())) {log.info("Removing closed session {}", entry.getKey()); hasChanged[0] = true; return false; }).collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue())); log.info("Active sessions info fetched: {}", this.activeSessions.keySet()); return hasChanged[0]; EntityUtils.consumeQuietly(response.getEntity());
Thank you