diff --git a/openvidu-browser/src/OpenVidu/Session.ts b/openvidu-browser/src/OpenVidu/Session.ts index 450213f2..c83eea6c 100644 --- a/openvidu-browser/src/OpenVidu/Session.ts +++ b/openvidu-browser/src/OpenVidu/Session.ts @@ -77,7 +77,6 @@ const platform: PlatformUtils = PlatformUtils.getInstance(); * - networkQualityLevelChanged ([[NetworkQualityLevelChangedEvent]]) * - reconnecting * - reconnected - * */ export class Session extends EventDispatcher { @@ -1359,7 +1358,7 @@ export class Session extends EventDispatcher { private processJoinRoomResponse(opts: LocalConnectionOptions) { this.sessionId = opts.session; - if (!!opts.coturnIp && !!opts.turnUsername && !!opts.turnCredential) { + if (opts.coturnIp != null && opts.turnUsername != null && opts.turnCredential != null) { const stunUrl = 'stun:' + opts.coturnIp + ':3478'; const turnUrl1 = 'turn:' + opts.coturnIp + ':3478'; const turnUrl2 = turnUrl1 + '?transport=tcp'; diff --git a/openvidu-client/src/main/java/io/openvidu/client/internal/ProtocolElements.java b/openvidu-client/src/main/java/io/openvidu/client/internal/ProtocolElements.java index 52c6145d..f347c2cf 100644 --- a/openvidu-client/src/main/java/io/openvidu/client/internal/ProtocolElements.java +++ b/openvidu-client/src/main/java/io/openvidu/client/internal/ProtocolElements.java @@ -138,6 +138,14 @@ public class ProtocolElements { public static final String PARTICIPANTJOINED_USER_PARAM = "id"; public static final String PARTICIPANTJOINED_CREATEDAT_PARAM = "createdAt"; public static final String PARTICIPANTJOINED_METADATA_PARAM = "metadata"; + public static final String PARTICIPANTJOINED_VALUE_PARAM = "value"; + public static final String PARTICIPANTJOINED_SESSION_PARAM = "session"; + public static final String PARTICIPANTJOINED_VERSION_PARAM = "version"; + public static final String PARTICIPANTJOINED_RECORD_PARAM = "record"; + public static final String PARTICIPANTJOINED_ROLE_PARAM = "role"; + public static final String PARTICIPANTJOINED_COTURNIP_PARAM = "coturnIp"; + public static final String PARTICIPANTJOINED_TURNUSERNAME_PARAM = "turnUsername"; + public static final String PARTICIPANTJOINED_TURNCREDENTIAL_PARAM = "turnCredential"; public static final String PARTICIPANTLEFT_METHOD = "participantLeft"; public static final String PARTICIPANTLEFT_NAME_PARAM = "connectionId"; diff --git a/openvidu-server/src/main/java/io/openvidu/server/core/SessionEventsHandler.java b/openvidu-server/src/main/java/io/openvidu/server/core/SessionEventsHandler.java index 791b2be6..70f1fa6d 100644 --- a/openvidu-server/src/main/java/io/openvidu/server/core/SessionEventsHandler.java +++ b/openvidu-server/src/main/java/io/openvidu/server/core/SessionEventsHandler.java @@ -153,19 +153,23 @@ public class SessionEventsHandler { result.addProperty(ProtocolElements.PARTICIPANTJOINED_USER_PARAM, participant.getParticipantPublicId()); result.addProperty(ProtocolElements.PARTICIPANTJOINED_CREATEDAT_PARAM, participant.getActiveAt()); result.addProperty(ProtocolElements.PARTICIPANTJOINED_METADATA_PARAM, participant.getFullMetadata()); - result.add("value", resultArray); + result.add(ProtocolElements.PARTICIPANTJOINED_VALUE_PARAM, resultArray); - result.addProperty("session", participant.getSessionId()); - result.addProperty("version", openviduBuildConfig.getOpenViduServerVersion()); + result.addProperty(ProtocolElements.PARTICIPANTJOINED_SESSION_PARAM, participant.getSessionId()); + result.addProperty(ProtocolElements.PARTICIPANTJOINED_VERSION_PARAM, + openviduBuildConfig.getOpenViduServerVersion()); if (participant.getToken() != null) { - result.addProperty("record", participant.getToken().record()); + result.addProperty(ProtocolElements.PARTICIPANTJOINED_RECORD_PARAM, participant.getToken().record()); if (participant.getToken().getRole() != null) { - result.addProperty("role", participant.getToken().getRole().name()); + result.addProperty(ProtocolElements.PARTICIPANTJOINED_ROLE_PARAM, + participant.getToken().getRole().name()); } - result.addProperty("coturnIp", openviduConfig.getCoturnIp()); + result.addProperty(ProtocolElements.PARTICIPANTJOINED_COTURNIP_PARAM, openviduConfig.getCoturnIp()); if (participant.getToken().getTurnCredentials() != null) { - result.addProperty("turnUsername", participant.getToken().getTurnCredentials().getUsername()); - result.addProperty("turnCredential", participant.getToken().getTurnCredentials().getCredential()); + result.addProperty(ProtocolElements.PARTICIPANTJOINED_TURNUSERNAME_PARAM, + participant.getToken().getTurnCredentials().getUsername()); + result.addProperty(ProtocolElements.PARTICIPANTJOINED_TURNCREDENTIAL_PARAM, + participant.getToken().getTurnCredentials().getCredential()); } } diff --git a/openvidu-server/src/main/java/io/openvidu/server/core/Token.java b/openvidu-server/src/main/java/io/openvidu/server/core/Token.java index 2529badd..1501858d 100644 --- a/openvidu-server/src/main/java/io/openvidu/server/core/Token.java +++ b/openvidu-server/src/main/java/io/openvidu/server/core/Token.java @@ -39,7 +39,8 @@ public class Token { private final String connectionId = IdentifierPrefixes.PARTICIPANT_PUBLIC_ID + RandomStringUtils.randomAlphabetic(1).toUpperCase() + RandomStringUtils.randomAlphanumeric(9); - public Token(String token, String sessionId, ConnectionProperties connectionProperties, TurnCredentials turnCredentials) { + public Token(String token, String sessionId, ConnectionProperties connectionProperties, + TurnCredentials turnCredentials) { this.token = token; this.sessionId = sessionId; this.createdAt = System.currentTimeMillis(); @@ -67,15 +68,15 @@ public class Token { return this.connectionProperties.getData(); } - public boolean record() { + public Boolean record() { return this.connectionProperties.record(); } public void setRecord(boolean newRecord) { this.updateConnectionProperties(connectionProperties.getType(), connectionProperties.getData(), newRecord, - connectionProperties.getRole(), connectionProperties.getKurentoOptions(), connectionProperties.getRtspUri(), - connectionProperties.adaptativeBitrate(), connectionProperties.onlyPlayWithSubscribers(), - connectionProperties.getNetworkCache()); + connectionProperties.getRole(), connectionProperties.getKurentoOptions(), + connectionProperties.getRtspUri(), connectionProperties.adaptativeBitrate(), + connectionProperties.onlyPlayWithSubscribers(), connectionProperties.getNetworkCache()); } public OpenViduRole getRole() { diff --git a/openvidu-server/src/test/java/io/openvidu/server/test/integration/SessionGarbageCollectorIntegrationTest.java b/openvidu-server/src/test/java/io/openvidu/server/test/integration/SessionGarbageCollectorIntegrationTest.java index 9bb5d109..8b49bdc6 100644 --- a/openvidu-server/src/test/java/io/openvidu/server/test/integration/SessionGarbageCollectorIntegrationTest.java +++ b/openvidu-server/src/test/java/io/openvidu/server/test/integration/SessionGarbageCollectorIntegrationTest.java @@ -18,7 +18,6 @@ package io.openvidu.server.test.integration; import java.util.HashMap; -import java.util.Map; import java.util.UUID; import org.junit.Assert; @@ -103,9 +102,8 @@ public class SessionGarbageCollectorIntegrationTest { } private String getToken(String sessionId) { - Map map = new HashMap<>(); - map.put("session", sessionId); - String stringResponse = (String) sessionRestController.newToken(map).getBody(); + String stringResponse = (String) sessionRestController.initializeConnection(sessionId, new HashMap<>()) + .getBody(); return new Gson().fromJson(stringResponse, JsonObject.class).get("token").getAsString(); }