openvidu-server: RPC joinRoom params to ProtocolElements. Fix Token#getRecord

pull/553/head
pabloFuente 2020-10-22 21:28:23 +02:00
parent 7a26b25f12
commit 06fdc2de54
5 changed files with 29 additions and 19 deletions

View File

@ -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';

View File

@ -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";

View File

@ -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());
}
}

View File

@ -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() {

View File

@ -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<String, String> 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();
}