openvidu-server: "participantId" to "connectionId"

pull/609/head
pabloFuente 2021-02-02 11:32:24 +01:00
parent 8de0f838fd
commit b60466f8ee
10 changed files with 39 additions and 33 deletions

View File

@ -8,15 +8,15 @@ import com.google.gson.JsonObject;
public class CDREventFilterEvent extends CDREvent { public class CDREventFilterEvent extends CDREvent {
private GenericMediaEvent event; private GenericMediaEvent event;
private String participantId; private String connectionId;
private String streamId; private String streamId;
private String filterType; private String filterType;
public CDREventFilterEvent(String sessionId, String participantId, String streamId, String filterType, public CDREventFilterEvent(String sessionId, String connectionId, String streamId, String filterType,
GenericMediaEvent event) { GenericMediaEvent event) {
super(CDREventName.filterEventDispatched, sessionId, Long.parseLong(event.getTimestampMillis())); super(CDREventName.filterEventDispatched, sessionId, Long.parseLong(event.getTimestampMillis()));
this.event = event; this.event = event;
this.participantId = participantId; this.connectionId = connectionId;
this.streamId = streamId; this.streamId = streamId;
this.filterType = filterType; this.filterType = filterType;
} }
@ -32,7 +32,9 @@ public class CDREventFilterEvent extends CDREvent {
@Override @Override
public JsonObject toJson() { public JsonObject toJson() {
JsonObject json = super.toJson(); JsonObject json = super.toJson();
json.addProperty("participantId", this.participantId); // TODO: remove deprecated "participantId" when possible
json.addProperty("participantId", this.connectionId);
json.addProperty("connectionId", this.connectionId);
json.addProperty("streamId", this.streamId); json.addProperty("streamId", this.streamId);
json.addProperty("filterType", this.filterType); json.addProperty("filterType", this.filterType);
json.addProperty("eventType", this.event.getType()); json.addProperty("eventType", this.event.getType());

View File

@ -41,7 +41,9 @@ public class CDREventParticipant extends CDREventEnd {
@Override @Override
public JsonObject toJson() { public JsonObject toJson() {
JsonObject json = super.toJson(); JsonObject json = super.toJson();
// TODO: remove deprecated "participantId" when possible
json.addProperty("participantId", this.participant.getParticipantPublicId()); json.addProperty("participantId", this.participant.getParticipantPublicId());
json.addProperty("connectionId", this.participant.getParticipantPublicId());
json.addProperty("location", json.addProperty("location",
this.participant.getLocation() != null ? this.participant.getLocation().toString() : "unknown"); this.participant.getLocation() != null ? this.participant.getLocation().toString() : "unknown");
json.addProperty("platform", this.participant.getPlatform()); json.addProperty("platform", this.participant.getPlatform());

View File

@ -58,7 +58,9 @@ public class CDREventWebrtcConnection extends CDREventEnd implements Comparable<
public JsonObject toJson() { public JsonObject toJson() {
JsonObject json = super.toJson(); JsonObject json = super.toJson();
json.addProperty("streamId", this.streamId); json.addProperty("streamId", this.streamId);
// TODO: remove deprecated "participantId" when possible
json.addProperty("participantId", this.participant.getParticipantPublicId()); json.addProperty("participantId", this.participant.getParticipantPublicId());
json.addProperty("connectionId", this.participant.getParticipantPublicId());
if (this.receivingFrom != null) { if (this.receivingFrom != null) {
json.addProperty("connection", "INBOUND"); json.addProperty("connection", "INBOUND");
json.addProperty("receivingFrom", this.receivingFrom); json.addProperty("receivingFrom", this.receivingFrom);

View File

@ -180,9 +180,9 @@ public class CallDetailRecord {
this.log(new CDREventRecordingStatus(recording, recording.getCreatedAt(), finalReason, timestamp, status)); this.log(new CDREventRecordingStatus(recording, recording.getCreatedAt(), finalReason, timestamp, status));
} }
public void recordFilterEventDispatched(String sessionId, String participantId, String streamId, String filterType, public void recordFilterEventDispatched(String sessionId, String connectionId, String streamId, String filterType,
GenericMediaEvent event) { GenericMediaEvent event) {
this.log(new CDREventFilterEvent(sessionId, participantId, streamId, filterType, event)); this.log(new CDREventFilterEvent(sessionId, connectionId, streamId, filterType, event));
} }
public void recordSignalSent(String sessionId, String from, String[] to, String type, String data) { public void recordSignalSent(String sessionId, String from, String[] to, String type, String data) {

View File

@ -44,7 +44,7 @@ public class Participant {
} }
protected String finalUserId; // ID to match this connection with a final user (HttpSession id) protected String finalUserId; // ID to match this connection with a final user (HttpSession id)
protected String participantPrivatetId; // ID to identify the user on server (org.kurento.jsonrpc.Session.id) protected String participantPrivateId; // ID to identify the user on server (org.kurento.jsonrpc.Session.id)
protected String participantPublicId; // ID to identify the user on clients protected String participantPublicId; // ID to identify the user on clients
protected String sessionId; // ID of the session to which the participant belongs protected String sessionId; // ID of the session to which the participant belongs
protected ParticipantStatus status; // Status of the connection protected ParticipantStatus status; // Status of the connection
@ -75,11 +75,11 @@ public class Participant {
*/ */
public Lock singleRecordingLock = new ReentrantLock(); public Lock singleRecordingLock = new ReentrantLock();
public Participant(String finalUserId, String participantPrivatetId, String participantPublicId, String sessionId, public Participant(String finalUserId, String participantPrivateId, String participantPublicId, String sessionId,
Token token, String clientMetadata, GeoLocation location, String platform, EndpointType endpointType, Token token, String clientMetadata, GeoLocation location, String platform, EndpointType endpointType,
Long activeAt) { Long activeAt) {
this.finalUserId = finalUserId; this.finalUserId = finalUserId;
this.participantPrivatetId = participantPrivatetId; this.participantPrivateId = participantPrivateId;
this.participantPublicId = participantPublicId; this.participantPublicId = participantPublicId;
this.sessionId = sessionId; this.sessionId = sessionId;
this.status = ParticipantStatus.active; this.status = ParticipantStatus.active;
@ -102,11 +102,11 @@ public class Participant {
} }
public String getParticipantPrivateId() { public String getParticipantPrivateId() {
return participantPrivatetId; return participantPrivateId;
} }
public void setParticipantPrivateId(String participantPrivateId) { public void setParticipantPrivateId(String participantPrivateId) {
this.participantPrivatetId = participantPrivateId; this.participantPrivateId = participantPrivateId;
} }
public String getParticipantPublicId() { public String getParticipantPublicId() {
@ -210,7 +210,7 @@ public class Participant {
} }
public boolean isIpcam() { public boolean isIpcam() {
return this.platform != null && this.platform.equals("IPCAM") && this.participantPrivatetId.startsWith(IdentifierPrefixes.IPCAM_ID); return this.platform != null && this.platform.equals("IPCAM") && this.participantPrivateId.startsWith(IdentifierPrefixes.IPCAM_ID);
} }
public String getPublisherStreamId() { public String getPublisherStreamId() {
@ -245,7 +245,7 @@ public class Participant {
public int hashCode() { public int hashCode() {
final int prime = 31; final int prime = 31;
int result = 1; int result = 1;
result = prime * result + (participantPrivatetId == null ? 0 : participantPrivatetId.hashCode()); result = prime * result + (participantPrivateId == null ? 0 : participantPrivateId.hashCode());
result = prime * result + (streaming ? 1231 : 1237); result = prime * result + (streaming ? 1231 : 1237);
result = prime * result + (participantPublicId == null ? 0 : participantPublicId.hashCode()); result = prime * result + (participantPublicId == null ? 0 : participantPublicId.hashCode());
return result; return result;
@ -263,11 +263,11 @@ public class Participant {
return false; return false;
} }
Participant other = (Participant) obj; Participant other = (Participant) obj;
if (participantPrivatetId == null) { if (participantPrivateId == null) {
if (other.participantPrivatetId != null) { if (other.participantPrivateId != null) {
return false; return false;
} }
} else if (!participantPrivatetId.equals(other.participantPrivatetId)) { } else if (!participantPrivateId.equals(other.participantPrivateId)) {
return false; return false;
} }
if (streaming != other.streaming) { if (streaming != other.streaming) {
@ -287,8 +287,8 @@ public class Participant {
public String toString() { public String toString() {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append("["); builder.append("[");
if (participantPrivatetId != null) { if (participantPrivateId != null) {
builder.append("participantPrivateId=").append(participantPrivatetId).append(", "); builder.append("participantPrivateId=").append(participantPrivateId).append(", ");
} }
if (participantPublicId != null) { if (participantPublicId != null) {
builder.append("participantPublicId=").append(participantPublicId).append(", "); builder.append("participantPublicId=").append(participantPublicId).append(", ");

View File

@ -358,12 +358,12 @@ public abstract class SessionManager {
this.insecureUsers.put(participantPrivateId, true); this.insecureUsers.put(participantPrivateId, true);
} }
public Participant newParticipant(String sessionId, String participantPrivatetId, Token token, public Participant newParticipant(String sessionId, String participantPrivateId, Token token,
String clientMetadata, GeoLocation location, String platform, String finalUserId) { String clientMetadata, GeoLocation location, String platform, String finalUserId) {
if (this.sessionidParticipantpublicidParticipant.get(sessionId) != null) { if (this.sessionidParticipantpublicidParticipant.get(sessionId) != null) {
Participant p = new Participant(finalUserId, participantPrivatetId, token.getConnectionId(), sessionId, Participant p = new Participant(finalUserId, participantPrivateId, token.getConnectionId(), sessionId,
token, clientMetadata, location, platform, EndpointType.WEBRTC_ENDPOINT, null); token, clientMetadata, location, platform, EndpointType.WEBRTC_ENDPOINT, null);
this.sessionidParticipantpublicidParticipant.get(sessionId).put(p.getParticipantPublicId(), p); this.sessionidParticipantpublicidParticipant.get(sessionId).put(p.getParticipantPublicId(), p);
@ -381,10 +381,10 @@ public abstract class SessionManager {
} }
} }
public Participant newRecorderParticipant(String sessionId, String participantPrivatetId, Token token, public Participant newRecorderParticipant(String sessionId, String participantPrivateId, Token token,
String clientMetadata) { String clientMetadata) {
if (this.sessionidParticipantpublicidParticipant.get(sessionId) != null) { if (this.sessionidParticipantpublicidParticipant.get(sessionId) != null) {
Participant p = new Participant(null, participantPrivatetId, ProtocolElements.RECORDER_PARTICIPANT_PUBLICID, Participant p = new Participant(null, participantPrivateId, ProtocolElements.RECORDER_PARTICIPANT_PUBLICID,
sessionId, token, clientMetadata, null, null, EndpointType.WEBRTC_ENDPOINT, null); sessionId, token, clientMetadata, null, null, EndpointType.WEBRTC_ENDPOINT, null);
this.sessionidParticipantpublicidParticipant.get(sessionId) this.sessionidParticipantpublicidParticipant.get(sessionId)
.put(ProtocolElements.RECORDER_PARTICIPANT_PUBLICID, p); .put(ProtocolElements.RECORDER_PARTICIPANT_PUBLICID, p);

View File

@ -164,8 +164,8 @@ public class KurentoSession extends Session {
candidate); candidate);
} }
public void sendMediaError(String participantId, String description) { public void sendMediaError(String connectionId, String description) {
this.kurentoSessionHandler.onMediaElementError(sessionId, participantId, description); this.kurentoSessionHandler.onMediaElementError(sessionId, connectionId, description);
} }
private void removeParticipant(Participant participant, EndReason reason) { private void removeParticipant(Participant participant, EndReason reason) {

View File

@ -50,10 +50,10 @@ public class KurentoSessionEventsHandler extends SessionEventsHandler {
} }
} }
public void onMediaElementError(String roomName, String participantId, String description) { public void onMediaElementError(String roomName, String connectionId, String description) {
JsonObject notifParams = new JsonObject(); JsonObject notifParams = new JsonObject();
notifParams.addProperty(ProtocolElements.MEDIAERROR_ERROR_PARAM, description); notifParams.addProperty(ProtocolElements.MEDIAERROR_ERROR_PARAM, description);
rpcNotificationService.sendNotification(participantId, ProtocolElements.MEDIAERROR_METHOD, notifParams); rpcNotificationService.sendNotification(connectionId, ProtocolElements.MEDIAERROR_METHOD, notifParams);
} }
} }

View File

@ -181,7 +181,7 @@ public class RpcHandler extends DefaultJsonRpcHandler<JsonObject> {
String token = getStringParam(request, ProtocolElements.JOINROOM_TOKEN_PARAM); String token = getStringParam(request, ProtocolElements.JOINROOM_TOKEN_PARAM);
String secret = getStringParam(request, ProtocolElements.JOINROOM_SECRET_PARAM); String secret = getStringParam(request, ProtocolElements.JOINROOM_SECRET_PARAM);
String platform = getStringParam(request, ProtocolElements.JOINROOM_PLATFORM_PARAM); String platform = getStringParam(request, ProtocolElements.JOINROOM_PLATFORM_PARAM);
String participantPrivatetId = rpcConnection.getParticipantPrivateId(); String participantPrivateId = rpcConnection.getParticipantPrivateId();
final io.openvidu.server.core.Session session = sessionManager.getSessionWithNotActive(sessionId); final io.openvidu.server.core.Session session = sessionManager.getSessionWithNotActive(sessionId);
if (session == null) { if (session == null) {
@ -245,7 +245,7 @@ public class RpcHandler extends DefaultJsonRpcHandler<JsonObject> {
boolean generateRecorderParticipant = false; boolean generateRecorderParticipant = false;
if (openviduConfig.isOpenViduSecret(secret)) { if (openviduConfig.isOpenViduSecret(secret)) {
sessionManager.newInsecureParticipant(participantPrivatetId); sessionManager.newInsecureParticipant(participantPrivateId);
token = IdentifierPrefixes.TOKEN_ID + RandomStringUtils.randomAlphabetic(1).toUpperCase() token = IdentifierPrefixes.TOKEN_ID + RandomStringUtils.randomAlphabetic(1).toUpperCase()
+ RandomStringUtils.randomAlphanumeric(15); + RandomStringUtils.randomAlphanumeric(15);
try { try {
@ -274,10 +274,10 @@ public class RpcHandler extends DefaultJsonRpcHandler<JsonObject> {
} }
Participant participant; Participant participant;
if (generateRecorderParticipant) { if (generateRecorderParticipant) {
participant = sessionManager.newRecorderParticipant(sessionId, participantPrivatetId, participant = sessionManager.newRecorderParticipant(sessionId, participantPrivateId,
tokenObj, clientMetadata); tokenObj, clientMetadata);
} else { } else {
participant = sessionManager.newParticipant(sessionId, participantPrivatetId, tokenObj, participant = sessionManager.newParticipant(sessionId, participantPrivateId, tokenObj,
clientMetadata, location, platform, clientMetadata, location, platform,
httpSession.getId().substring(0, Math.min(16, httpSession.getId().length()))); httpSession.getId().substring(0, Math.min(16, httpSession.getId().length())));
} }
@ -291,7 +291,7 @@ public class RpcHandler extends DefaultJsonRpcHandler<JsonObject> {
} else { } else {
log.error( log.error(
"ERROR: The session {} is in the process of closing while participant {} (privateId) was joining", "ERROR: The session {} is in the process of closing while participant {} (privateId) was joining",
sessionId, participantPrivatetId); sessionId, participantPrivateId);
throw new OpenViduException(Code.ROOM_CLOSED_ERROR_CODE, throw new OpenViduException(Code.ROOM_CLOSED_ERROR_CODE,
"Unable to join the session. Session " + sessionId + " was in the process of closing"); "Unable to join the session. Session " + sessionId + " was in the process of closing");
} }

View File

@ -3333,7 +3333,7 @@ public class OpenViduTestAppE2eTest extends AbstractOpenViduTestAppE2eTest {
event = CustomWebhook.waitForEvent("webrtcConnectionCreated", 2); event = CustomWebhook.waitForEvent("webrtcConnectionCreated", 2);
Assert.assertEquals("Wrong number of properties in event 'webrtcConnectionCreated'", 10 + 1, Assert.assertEquals("Wrong number of properties in event 'webrtcConnectionCreated'", 10 + 1,
event.keySet().size()); event.keySet().size());
String connectionId1 = event.get("participantId").getAsString(); String connectionId1 = event.get("connectionId").getAsString();
event = CustomWebhook.waitForEvent("recordingStatusChanged", 10); event = CustomWebhook.waitForEvent("recordingStatusChanged", 10);
Assert.assertEquals("Wrong number of properties in event 'recordingStatusChanged'", 11 + 1, Assert.assertEquals("Wrong number of properties in event 'recordingStatusChanged'", 11 + 1,
@ -3380,7 +3380,7 @@ public class OpenViduTestAppE2eTest extends AbstractOpenViduTestAppE2eTest {
CustomWebhook.waitForEvent("webrtcConnectionCreated", 2); CustomWebhook.waitForEvent("webrtcConnectionCreated", 2);
CustomWebhook.waitForEvent("webrtcConnectionCreated", 2); CustomWebhook.waitForEvent("webrtcConnectionCreated", 2);
String connectionId2 = event.get("participantId").getAsString(); String connectionId2 = event.get("connectionId").getAsString();
// signalSent from client // signalSent from client
long timestamp = System.currentTimeMillis(); long timestamp = System.currentTimeMillis();