openvidu-server: ParticipantSummary protection against lack of participantLeft event

pull/437/head
pabloFuente 2020-04-14 21:33:17 +02:00
parent 4c50f84b7d
commit 74e7943e26
1 changed files with 15 additions and 4 deletions

View File

@ -20,6 +20,9 @@ package io.openvidu.server.summary;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
@ -29,6 +32,8 @@ import io.openvidu.server.core.Participant;
public class ParticipantSummary { public class ParticipantSummary {
private static final Logger log = LoggerFactory.getLogger(ParticipantSummary.class);
private CDREventParticipant eventParticipantEnd; private CDREventParticipant eventParticipantEnd;
private Map<String, CDREventWebrtcConnection> publishers = new ConcurrentHashMap<>(); private Map<String, CDREventWebrtcConnection> publishers = new ConcurrentHashMap<>();
private Map<String, CDREventWebrtcConnection> subscribers = new ConcurrentHashMap<>(); private Map<String, CDREventWebrtcConnection> subscribers = new ConcurrentHashMap<>();
@ -53,20 +58,26 @@ public class ParticipantSummary {
public JsonObject toJson() { public JsonObject toJson() {
JsonObject json = new JsonObject(); JsonObject json = new JsonObject();
Participant p = this.eventParticipantEnd.getParticipant();
json.addProperty("createdAt", this.eventParticipantEnd.getStartTime()); Long START_TIME = this.eventParticipantEnd.getStartTime();
if (START_TIME == null) {
log.error("Participant {} startTime is not defined", p.getParticipantPublicId());
log.error("Setting startTime to (endTime-1)", p.getParticipantPublicId());
START_TIME = this.eventParticipantEnd.getTimestamp() - 1;
}
json.addProperty("createdAt", START_TIME);
json.addProperty("destroyedAt", this.eventParticipantEnd.getTimestamp()); json.addProperty("destroyedAt", this.eventParticipantEnd.getTimestamp());
Participant p = this.eventParticipantEnd.getParticipant();
json.addProperty("connectionId", p.getParticipantPublicId()); json.addProperty("connectionId", p.getParticipantPublicId());
json.addProperty("clientData", p.getClientMetadata()); json.addProperty("clientData", p.getClientMetadata());
json.addProperty("serverData", p.getServerMetadata()); json.addProperty("serverData", p.getServerMetadata());
long duration = (this.eventParticipantEnd.getTimestamp() - this.eventParticipantEnd.getStartTime()) / 1000; long duration = (this.eventParticipantEnd.getTimestamp() - START_TIME) / 1000;
json.addProperty("duration", duration); json.addProperty("duration", duration);
json.addProperty("reason", json.addProperty("reason",
this.eventParticipantEnd.getReason().name() != null ? this.eventParticipantEnd.getReason().name() : ""); this.eventParticipantEnd.getReason() != null ? this.eventParticipantEnd.getReason().name() : "NULL");
// Publishers summary // Publishers summary
JsonObject publishersJson = new JsonObject(); JsonObject publishersJson = new JsonObject();