openvidu-server: add new "object" and "id" properties to REST entities

pull/550/head
pabloFuente 2020-10-13 12:21:14 +02:00
parent 67c50862bb
commit 9e957eddf5
5 changed files with 29 additions and 5 deletions

View File

@ -271,7 +271,9 @@ public class Participant {
public JsonObject toJson() {
JsonObject json = new JsonObject();
json.addProperty("connectionId", this.participantPublicId);
json.addProperty("id", this.participantPublicId);
json.addProperty("object", "connection");
json.addProperty("connectionId", this.participantPublicId); // TODO: deprecated. Better use only "id"
json.addProperty("sessionId", this.sessionId);
json.addProperty("createdAt", this.createdAt);
json.addProperty("location", this.location != null ? this.location.toString() : "unknown");

View File

@ -224,8 +224,9 @@ public class Session implements SessionInterface {
private JsonObject sharedJson(Function<KurentoParticipant, JsonObject> toJsonFunction) {
JsonObject json = new JsonObject();
json.addProperty("sessionId", this.sessionId);
json.addProperty("id", this.sessionId); // TODO: deprecated. Better use only "sessionId"
json.addProperty("id", this.sessionId);
json.addProperty("object", "session");
json.addProperty("sessionId", this.sessionId); // TODO: deprecated. Better use only "id"
json.addProperty("createdAt", this.startTime);
json.addProperty("mediaMode", this.sessionProperties.mediaMode().name());
json.addProperty("recordingMode", this.sessionProperties.recordingMode().name());

View File

@ -91,8 +91,9 @@ public class Token {
public JsonObject toJson() {
JsonObject json = new JsonObject();
json.addProperty("token", this.getToken());
json.addProperty("id", this.getToken());
json.addProperty("object", "token");
json.addProperty("token", this.getToken());
json.addProperty("connectionId", this.getConnectionId());
json.addProperty("session", this.sessionId);
json.addProperty("role", this.getRole().toString());
@ -104,6 +105,25 @@ public class Token {
return json;
}
public JsonObject toJsonAsParticipant() {
JsonObject json = new JsonObject();
json.addProperty("id", this.getConnectionId());
json.addProperty("object", "connection");
json.addProperty("connectionId", this.getConnectionId()); // DEPRECATED: better use id
json.addProperty("sessionId", this.sessionId);
json.add("createdAt", null);
json.add("location", null);
json.add("platform", null);
json.addProperty("token", this.getToken());
json.addProperty("role", this.getRole().toString());
json.addProperty("serverData", this.getServerMetadata());
json.addProperty("record", this.record());
json.add("clientData", null);
json.add("publishers", null);
json.add("subscribers", null);
return json;
}
@Override
public String toString() {
if (this.role != null)

View File

@ -152,9 +152,9 @@ public class Kms {
public JsonObject toJson() {
JsonObject json = new JsonObject();
json.addProperty("id", this.id);
json.addProperty("object", "mediaNode");
json.addProperty("ip", this.ip);
json.addProperty("uri", this.uri);
final boolean connected = this.isKurentoClientConnected();
json.addProperty("connected", connected);
json.addProperty("connectionTime", this.getTimeOfKurentoClientConnection());

View File

@ -191,6 +191,7 @@ public class Recording {
public JsonObject toJson() {
JsonObject json = new JsonObject();
json.addProperty("id", this.id);
json.addProperty("object", "recording");
json.addProperty("name", this.recordingProperties.name());
json.addProperty("outputMode", this.getOutputMode().name());
if (RecordingUtils.IS_COMPOSED(this.recordingProperties.outputMode()) && this.hasVideo) {