mirror of https://github.com/OpenVidu/openvidu.git
openvidu-server: common KmsEvent toJson
parent
16ccaae268
commit
a2a7828c9d
|
@ -17,9 +17,8 @@
|
|||
|
||||
package io.openvidu.server.kurento.endpoint;
|
||||
|
||||
import org.kurento.client.ErrorEvent;
|
||||
import org.kurento.client.MediaEvent;
|
||||
import org.kurento.client.RaiseBaseEvent;
|
||||
import org.kurento.jsonrpc.JsonUtils;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
|
@ -44,22 +43,12 @@ public class KmsEvent {
|
|||
}
|
||||
|
||||
public JsonObject toJson() {
|
||||
JsonObject json = new JsonObject();
|
||||
|
||||
if (event instanceof ErrorEvent) {
|
||||
ErrorEvent errorEvent = (ErrorEvent) event;
|
||||
json.addProperty("eventType", errorEvent.getType());
|
||||
json.addProperty("errorCode", errorEvent.getErrorCode());
|
||||
json.addProperty("description", errorEvent.getDescription());
|
||||
} else {
|
||||
MediaEvent mediaEvent = (MediaEvent) event;
|
||||
json.addProperty("eventType", mediaEvent.getType());
|
||||
}
|
||||
|
||||
JsonObject json = JsonUtils.toJsonObject(event);
|
||||
json.remove("tags");
|
||||
json.addProperty("timestamp", timestamp);
|
||||
json.addProperty("session", sessionId);
|
||||
json.addProperty("connection", connectionId);
|
||||
json.addProperty("endpoint", this.endpoint);
|
||||
json.addProperty("timestamp", timestamp);
|
||||
json.addProperty("msSinceEndpointCreation", msSinceCreation);
|
||||
return json;
|
||||
}
|
||||
|
|
|
@ -34,7 +34,6 @@ import org.kurento.client.OnIceCandidateEvent;
|
|||
import org.kurento.client.RtpEndpoint;
|
||||
import org.kurento.client.SdpEndpoint;
|
||||
import org.kurento.client.WebRtcEndpoint;
|
||||
import org.kurento.jsonrpc.JsonUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -501,14 +500,13 @@ public abstract class MediaEndpoint {
|
|||
}
|
||||
|
||||
JsonArray jsonArray = new JsonArray();
|
||||
for (KmsEvent event : this.kmsEvents) {
|
||||
JsonObject jsonKmsEvent = JsonUtils.toJsonObject(event.event);
|
||||
// Set custom more precise timestamp
|
||||
jsonKmsEvent.addProperty("timestamp", event.timestamp);
|
||||
// Set milliseconds since the Publisher or Subscriber started transmitting media
|
||||
jsonKmsEvent.addProperty("msSinceCreation", event.msSinceCreation);
|
||||
jsonArray.add(jsonKmsEvent);
|
||||
}
|
||||
this.kmsEvents.forEach(ev -> {
|
||||
JsonObject j = ev.toJson();
|
||||
j.remove("session");
|
||||
j.remove("connection");
|
||||
j.remove("endpoint");
|
||||
jsonArray.add(j);
|
||||
});
|
||||
json.add("events", jsonArray);
|
||||
|
||||
return json;
|
||||
|
|
Loading…
Reference in New Issue