Skip to content

Commit

Permalink
openvidu-server: POST Connection
Browse files Browse the repository at this point in the history
  • Loading branch information
pabloFuente committed Oct 19, 2020
1 parent 43f2f26 commit 759acb1
Show file tree
Hide file tree
Showing 9 changed files with 284 additions and 198 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package io.openvidu.server.core;

public enum ConnectionType {
WEBRTC, IPCAM
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ enum ParticipantStatus {
active
}

protected ConnectionType type; // WEBRTC, IPCAM
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 participantPublicId; // ID to identify the user on clients
Expand Down Expand Up @@ -76,9 +77,10 @@ enum ParticipantStatus {
*/
public Lock singleRecordingLock = new ReentrantLock();

public Participant(String finalUserId, String participantPrivatetId, String participantPublicId, String sessionId,
Token token, String clientMetadata, GeoLocation location, String platform, EndpointType endpointType,
Long activeAt) {
public Participant(ConnectionType type, String finalUserId, String participantPrivatetId,
String participantPublicId, String sessionId, Token token, String clientMetadata, GeoLocation location,
String platform, EndpointType endpointType, Long activeAt) {
this.type = type;
this.finalUserId = finalUserId;
this.participantPrivatetId = participantPrivatetId;
this.participantPublicId = participantPublicId;
Expand All @@ -101,6 +103,10 @@ public Participant(String finalUserId, String participantPrivatetId, String part
this.endpointType = endpointType;
}

public ConnectionType getType() {
return type;
}

public String getFinalUserId() {
return finalUserId;
}
Expand Down Expand Up @@ -300,6 +306,7 @@ public JsonObject toJson() {
JsonObject json = new JsonObject();
json.addProperty("id", this.participantPublicId);
json.addProperty("object", "connection");
json.addProperty("type", this.type.name());
json.addProperty("status", this.status.name());
json.addProperty("connectionId", this.participantPublicId); // TODO: deprecated. Better use only "id"
json.addProperty("sessionId", this.sessionId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,9 @@ public Participant newParticipant(String sessionId, String participantPrivatetId

if (this.sessionidParticipantpublicidParticipant.get(sessionId) != null) {

Participant p = new Participant(finalUserId, participantPrivatetId, token.getConnectionId(), sessionId,
token, clientMetadata, location, platform, EndpointType.WEBRTC_ENDPOINT, null);
Participant p = new Participant(ConnectionType.WEBRTC, finalUserId, participantPrivatetId,
token.getConnectionId(), sessionId, token, clientMetadata, location, platform,
EndpointType.WEBRTC_ENDPOINT, null);

this.sessionidParticipantpublicidParticipant.get(sessionId).put(p.getParticipantPublicId(), p);

Expand All @@ -384,8 +385,9 @@ public Participant newParticipant(String sessionId, String participantPrivatetId
public Participant newRecorderParticipant(String sessionId, String participantPrivatetId, Token token,
String clientMetadata) {
if (this.sessionidParticipantpublicidParticipant.get(sessionId) != null) {
Participant p = new Participant(null, participantPrivatetId, ProtocolElements.RECORDER_PARTICIPANT_PUBLICID,
sessionId, token, clientMetadata, null, null, EndpointType.WEBRTC_ENDPOINT, null);
Participant p = new Participant(ConnectionType.WEBRTC, null, participantPrivatetId,
ProtocolElements.RECORDER_PARTICIPANT_PUBLICID, sessionId, token, clientMetadata, null, null,
EndpointType.WEBRTC_ENDPOINT, null);
this.sessionidParticipantpublicidParticipant.get(sessionId)
.put(ProtocolElements.RECORDER_PARTICIPANT_PUBLICID, p);
return p;
Expand All @@ -397,8 +399,8 @@ public Participant newRecorderParticipant(String sessionId, String participantPr
public Participant newIpcamParticipant(String sessionId, String ipcamId, Token token, GeoLocation location,
String platform) {
if (this.sessionidParticipantpublicidParticipant.get(sessionId) != null) {
Participant p = new Participant(ipcamId, ipcamId, ipcamId, sessionId, token, null, location, platform,
EndpointType.PLAYER_ENDPOINT, null);
Participant p = new Participant(ConnectionType.IPCAM, ipcamId, ipcamId, ipcamId, sessionId, token, null,
location, platform, EndpointType.PLAYER_ENDPOINT, null);
this.sessionidParticipantpublicidParticipant.get(sessionId).put(ipcamId, p);
return p;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ public JsonObject toJsonAsParticipant() {
JsonObject json = new JsonObject();
json.addProperty("id", this.getConnectionId());
json.addProperty("object", "connection");
json.addProperty("type", ConnectionType.WEBRTC.name());
json.addProperty("status", ParticipantStatus.pending.name());
json.addProperty("connectionId", this.getConnectionId()); // DEPRECATED: better use id
json.addProperty("sessionId", this.sessionId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public class KurentoParticipant extends Participant {
public KurentoParticipant(Participant participant, KurentoSession kurentoSession,
KurentoParticipantEndpointConfig endpointConfig, OpenviduConfig openviduConfig,
RecordingManager recordingManager) {
super(participant.getFinalUserId(), participant.getParticipantPrivateId(), participant.getParticipantPublicId(),
super(participant.getType(), participant.getFinalUserId(), participant.getParticipantPrivateId(), participant.getParticipantPublicId(),
kurentoSession.getSessionId(), participant.getToken(), participant.getClientMetadata(),
participant.getLocation(), participant.getPlatform(), participant.getEndpointType(),
participant.getActiveAt());
Expand Down
Loading

0 comments on commit 759acb1

Please sign in to comment.