ConnectionPropertyChanged event

pull/553/head
pabloFuente 2020-10-22 20:42:54 +02:00
parent 4ce089acb8
commit 7a26b25f12
14 changed files with 214 additions and 39 deletions

View File

@ -51,6 +51,23 @@ export class Connection {
*/
data: string;
/**
* Role of the connection.
* - `SUBSCRIBER`: can subscribe to published Streams of other users by calling [[Session.subscribe]]
* - `PUBLISHER`: SUBSCRIBER permissions + can publish their own Streams by calling [[Session.publish]]
* - `MODERATOR`: SUBSCRIBER + PUBLISHER permissions + can force the unpublishing or disconnection over a third-party Stream or Connection by call [[Session.forceUnpublish]] and [[Session.forceDisconnect]]
*
* **Only defined for the local connection. In remote connections will be `undefined`**
*/
role: string;
/**
* Whether the streams published by this connection will be recorded or not. This only affects [INDIVIDUAL recording](/en/stable/advanced-features/recording#selecting-streams-to-be-recorded) <a href="https://docs.openvidu.io/en/stable/openvidu-pro/" target="_blank" style="display: inline-block; background-color: rgb(0, 136, 170); color: white; font-weight: bold; padding: 0px 5px; margin-right: 5px; border-radius: 3px; font-size: 13px; line-height:21px; font-family: Montserrat, sans-serif">PRO</a>
*
* **Only defined for the local connection. In remote connections will be `undefined`**
*/
record: boolean;
/**
* @hidden
*/
@ -88,6 +105,8 @@ export class Connection {
this.creationTime = this.localOptions.createdAt;
this.data = this.localOptions.metadata;
this.rpcSessionId = this.localOptions.sessionId;
this.role = this.localOptions.role;
this.record = this.localOptions.record;
msg += '(local)';
} else {
// Connection is remote

View File

@ -759,6 +759,7 @@ export class OpenVidu {
recordingStopped: this.session.onRecordingStopped.bind(this.session),
sendMessage: this.session.onNewMessage.bind(this.session),
streamPropertyChanged: this.session.onStreamPropertyChanged.bind(this.session),
connectionPropertyChanged: this.session.onConnectionPropertyChanged.bind(this.session),
networkQualityLevelChanged: this.session.onNetworkQualityLevelChangedChanged.bind(this.session),
filterEventDispatched: this.session.onFilterEventDispatched.bind(this.session),
iceCandidate: this.session.recvIceCandidate.bind(this.session),

View File

@ -38,6 +38,7 @@ import { SessionDisconnectedEvent } from '../OpenViduInternal/Events/SessionDisc
import { SignalEvent } from '../OpenViduInternal/Events/SignalEvent';
import { StreamEvent } from '../OpenViduInternal/Events/StreamEvent';
import { StreamPropertyChangedEvent } from '../OpenViduInternal/Events/StreamPropertyChangedEvent';
import { ConnectionPropertyChangedEvent } from '../OpenViduInternal/Events/ConnectionPropertyChangedEvent';
import { NetworkQualityLevelChangedEvent } from '../OpenViduInternal/Events/NetworkQualityLevelChangedEvent';
import { OpenViduError, OpenViduErrorName } from '../OpenViduInternal/Enums/OpenViduError';
import { VideoInsertMode } from '../OpenViduInternal/Enums/VideoInsertMode';
@ -63,6 +64,7 @@ const platform: PlatformUtils = PlatformUtils.getInstance();
*
* - connectionCreated ([[ConnectionEvent]])
* - connectionDestroyed ([[ConnectionEvent]])
* - connectionPropertyChanged ([[ConnectionPropertyChangedEvent]]) <a href="https://docs.openvidu.io/en/stable/openvidu-pro/" target="_blank" style="display: inline-block; background-color: rgb(0, 136, 170); color: white; font-weight: bold; padding: 0px 5px; margin-right: 5px; border-radius: 3px; font-size: 13px; line-height:21px; font-family: Montserrat, sans-serif">PRO</a>
* - sessionDisconnected ([[SessionDisconnectedEvent]])
* - streamCreated ([[StreamEvent]])
* - streamDestroyed ([[StreamEvent]])
@ -95,7 +97,7 @@ export class Session extends EventDispatcher {
streamManagers: StreamManager[] = [];
/**
* Object defining the methods that the client is able to call. These are defined by the role of the token used to connect to the Session.
* Object defining the methods that the client is able to call. These are defined by the [[Connection.role]].
* This object is only defined after [[Session.connect]] has been successfully resolved
*/
capabilities: Capabilities;
@ -930,6 +932,26 @@ export class Session extends EventDispatcher {
}
}
/**
* @hidden
*/
onConnectionPropertyChanged(msg): void {
let oldValue;
switch (msg.property) {
case 'role':
oldValue = this.connection.role.slice();
this.connection.role = msg.newValue;
this.connection.localOptions!.role = msg.newValue;
break;
case 'record':
oldValue = this.connection.record;
msg.newValue = msg.newValue === 'true';
this.connection.record = msg.newValue;
this.connection.localOptions!.record = msg.newValue;
break;
}
this.ee.emitEvent('connectionPropertyChanged', [new ConnectionPropertyChangedEvent(this, this.connection, msg.property, msg.newValue, oldValue)]);
}
/**
* @hidden

View File

@ -0,0 +1,74 @@
/*
* (C) Copyright 2017-2020 OpenVidu (https://openvidu.io)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import { Connection } from '../../OpenVidu/Connection';
import { Session } from '../../OpenVidu/Session';
import { Event } from './Event';
/**
* **This feature is part of OpenVidu Pro tier** <a href="https://docs.openvidu.io/en/stable/openvidu-pro/" target="_blank" style="display: inline-block; background-color: rgb(0, 136, 170); color: white; font-weight: bold; padding: 0px 5px; margin-right: 5px; border-radius: 3px; font-size: 13px; line-height:21px; font-family: Montserrat, sans-serif">PRO</a>
*
* Defines event `connectionPropertyChanged` dispatched by [[Session]] object.
* This event is fired when any property of the local [[Connection]] object changes.
* The properties that may change are [[Connection.role]] and [[Connection.record]].
*
* The only way the Connection properties may change is by updating them through:
*
* - [API REST](/en/stable/reference-docs/REST-API/#patch-openviduapisessionsltsession_idgtconnectionltconnection_idgt)
* - [openvidu-java-client](/en/stable/reference-docs/openvidu-java-client/#update-a-connection)
* - [openvidu-node-client](/en/stable/reference-docs/openvidu-node-client/#update-a-connection)<br><br>
*/
export class ConnectionPropertyChangedEvent extends Event {
/**
* The Connection whose property has changed
*/
connection: Connection;
/**
* The property of the stream that changed. This value is either `"role"` or `"record"`
*/
changedProperty: string;
/**
* New value of the property (after change, current value)
*/
newValue: Object;
/**
* Previous value of the property (before change)
*/
oldValue: Object;
/**
* @hidden
*/
constructor(target: Session, connection: Connection, changedProperty: string, newValue: Object, oldValue: Object) {
super(false, target, 'connectionPropertyChanged');
this.connection = connection;
this.changedProperty = changedProperty;
this.newValue = newValue;
this.oldValue = oldValue;
}
/**
* @hidden
*/
// tslint:disable-next-line:no-empty
callDefaultBehavior() { }
}

View File

@ -20,8 +20,10 @@ import { Session } from '../../OpenVidu/Session';
import { Connection } from '../../OpenVidu/Connection';
/**
* **This feature is part of OpenVidu Pro tier** <a href="https://docs.openvidu.io/en/stable/openvidu-pro/" target="_blank" style="display: inline-block; background-color: rgb(0, 136, 170); color: white; font-weight: bold; padding: 0px 5px; margin-right: 5px; border-radius: 3px; font-size: 13px; line-height:21px; font-family: Montserrat, sans-serif">PRO</a>
*
* Defines event `networkQualityLevelChanged` dispatched by [[Session]].
* This event is fired when the network quality level of a [[Connection]] changes.
* This event is fired when the network quality level of a [[Connection]] changes. See [network quality](/en/stable/advanced-features/network-quality/)
*/
export class NetworkQualityLevelChangedEvent extends Event {

View File

@ -25,6 +25,7 @@ export interface LocalConnectionOptions {
session: string; // OpenVidu Session identifier
sessionId: string; // JSON-RPC session identifier
role: string;
record: boolean;
coturnIp: string;
turnUsername: string;
turnCredential: string;

View File

@ -22,6 +22,7 @@ export { StreamEvent } from './OpenViduInternal/Events/StreamEvent';
export { StreamManagerEvent } from './OpenViduInternal/Events/StreamManagerEvent';
export { VideoElementEvent } from './OpenViduInternal/Events/VideoElementEvent';
export { StreamPropertyChangedEvent } from './OpenViduInternal/Events/StreamPropertyChangedEvent';
export { ConnectionPropertyChangedEvent } from './OpenViduInternal/Events/ConnectionPropertyChangedEvent';
export { FilterEvent } from './OpenViduInternal/Events/FilterEvent';
export { NetworkQualityLevelChangedEvent } from './OpenViduInternal/Events/NetworkQualityLevelChangedEvent';

View File

@ -93,6 +93,10 @@ public class ProtocolElements {
public static final String STREAMPROPERTYCHANGED_NEWVALUE_PARAM = "newValue";
public static final String STREAMPROPERTYCHANGED_REASON_PARAM = "reason";
public static final String CONNECTIONPERTYCHANGED_METHOD = "connectionPropertyChanged";
public static final String CONNECTIONROPERTYCHANGED_PROPERTY_PARAM = "property";
public static final String CONNECTIONPROPERTYCHANGED_NEWVALUE_PARAM = "newValue";
public static final String NETWORKQUALITYLEVELCHANGED_METHOD = "networkQualityLevelChanged";
public static final String NETWORKQUALITYCHANGED_CONNECTIONID_PARAM = "connectionId";
public static final String NETWORKQUALITYCHANGED_QUALITYLEVEL_PARAM = "qualityLevel";

View File

@ -463,9 +463,12 @@ public class Session {
}
/**
* Updates the properties of a Connection with a
* {@link io.openvidu.java.client.ConnectionProperties} object. Only these
* properties can be updated:
* <a href="https://docs.openvidu.io/en/stable/openvidu-pro/" target="_blank"
* style="display: inline-block; background-color: rgb(0, 136, 170); color:
* white; font-weight: bold; padding: 0px 5px; margin-right: 5px; border-radius:
* 3px; font-size: 13px; line-height:21px; font-family: Montserrat,
* sans-serif">PRO</a> Updates the properties of a Connection with a
* {@link io.openvidu.java.client.ConnectionProperties} object. Only these properties can be updated:
* <ul>
* <li>{@link io.openvidu.java.client.ConnectionProperties.Builder#role(OpenViduRole)
* ConnectionProperties.Builder.role(OpenViduRole)}</li>
@ -481,9 +484,9 @@ public class Session {
* changes consequence of the execution of this method applied in the local
* objects.
*
* @param connectionId The Connection to modify
* @param connectionProperties A ConnectionProperties object with the new values to
* apply
* @param connectionId The Connection to modify
* @param connectionProperties A ConnectionProperties object with the new values
* to apply
*
* @return The updated {@link io.openvidu.java.client.Connection Connection}
* object

View File

@ -49,7 +49,7 @@ export class Session {
* **will remain unchanged since the last time method [[Session.fetch]] or [[OpenVidu.fetch]] was called**.
* Exceptions to this rule are:
*
* - Calling [[Session.createConnection]] automatically adds the new Connection object to the local collection.
* - Calling [[Session.createConnection]] automatically adds the new Connection object to the local collection.
* - Calling [[Session.forceUnpublish]] automatically updates each affected local Connection object.
* - Calling [[Session.forceDisconnect]] automatically updates each affected local Connection object.
* - Calling [[Session.updateConnection]] automatically updates the attributes of the affected local Connection object.
@ -390,6 +390,8 @@ export class Session {
}
/**
* **This feature is part of OpenVidu Pro tier** <a href="https://docs.openvidu.io/en/stable/openvidu-pro/" target="_blank" style="display: inline-block; background-color: rgb(0, 136, 170); color: white; font-weight: bold; padding: 0px 5px; margin-right: 5px; border-radius: 3px; font-size: 13px; line-height:21px; font-family: Montserrat, sans-serif">PRO</a>
*
* Updates the properties of a Connection with a [[ConnectionProperties]] object.
* Only these properties can be updated:
*
@ -420,8 +422,6 @@ export class Session {
.then(res => {
if (res.status === 200) {
console.log('Connection ' + connectionId + ' updated');
} else if (res.status === 204) {
console.log('Properties of Connection ' + connectionId + ' remain the same');
} else {
// ERROR response from openvidu-server. Resolve HTTP status
reject(new Error(res.status.toString()));

View File

@ -61,7 +61,7 @@ public class SessionEventsHandler {
@Autowired
protected OpenviduBuildInfo openviduBuildConfig;
private Map<String, Recording> recordingsToSendClientEvents = new ConcurrentHashMap<>();
protected Map<String, Recording> recordingsToSendClientEvents = new ConcurrentHashMap<>();
public void onSessionCreated(Session session) {
CDR.recordSessionCreated(session);
@ -155,17 +155,18 @@ public class SessionEventsHandler {
result.addProperty(ProtocolElements.PARTICIPANTJOINED_METADATA_PARAM, participant.getFullMetadata());
result.add("value", resultArray);
result.addProperty("session", participant.getSessionId());
result.addProperty("version", openviduBuildConfig.getOpenViduServerVersion());
if (participant.getToken() != null) {
result.addProperty("session", participant.getSessionId());
result.addProperty("coturnIp", openviduConfig.getCoturnIp());
result.addProperty("record", participant.getToken().record());
if (participant.getToken().getRole() != null) {
result.addProperty("role", participant.getToken().getRole().name());
}
result.addProperty("coturnIp", openviduConfig.getCoturnIp());
if (participant.getToken().getTurnCredentials() != null) {
result.addProperty("turnUsername", participant.getToken().getTurnCredentials().getUsername());
result.addProperty("turnCredential", participant.getToken().getTurnCredentials().getCredential());
}
result.addProperty("version", openviduBuildConfig.getOpenViduServerVersion());
}
rpcNotificationService.sendResponse(participant.getParticipantPrivateId(), transactionId, result);
@ -315,13 +316,6 @@ public class SessionEventsHandler {
rpcNotificationService.sendResponse(participant.getParticipantPrivateId(), transactionId, new JsonObject());
}
public void onNetworkQualityLevelChanged(Session session, JsonObject params) {
session.getParticipants().forEach(p -> {
rpcNotificationService.sendNotification(p.getParticipantPrivateId(),
ProtocolElements.NETWORKQUALITYLEVELCHANGED_METHOD, params);
});
}
public void onSendMessage(Participant participant, JsonObject message, Set<Participant> participants,
Integer transactionId, OpenViduException error) {
@ -593,7 +587,13 @@ public class SessionEventsHandler {
recordingsToSendClientEvents.put(recording.getSessionId(), recording);
}
private Set<Participant> filterParticipantsByRole(OpenViduRole[] roles, Set<Participant> participants) {
public void onNetworkQualityLevelChanged(Session session, JsonObject params) {
}
public void onConnectionPropertyChanged(Participant participant, String property, Object newValue) {
}
protected Set<Participant> filterParticipantsByRole(OpenViduRole[] roles, Set<Participant> participants) {
return participants.stream().filter(part -> {
if (ProtocolElements.RECORDER_PARTICIPANT_PUBLICID.equals(part.getParticipantPublicId())) {
return false;

View File

@ -29,9 +29,6 @@ import io.openvidu.server.core.SessionEventsHandler;
public class KurentoSessionEventsHandler extends SessionEventsHandler {
public KurentoSessionEventsHandler() {
}
public void onIceCandidate(String roomName, String participantPrivateId, String senderPublicId, String endpointName,
IceCandidate candidate) {
JsonObject params = new JsonObject();
@ -59,11 +56,4 @@ public class KurentoSessionEventsHandler extends SessionEventsHandler {
rpcNotificationService.sendNotification(participantId, ProtocolElements.MEDIAERROR_METHOD, notifParams);
}
public void updateFilter(String roomName, Participant participant, String filterId, String state) {
}
public String getNextFilterState(String filterId, String state) {
return null;
}
}

View File

@ -189,7 +189,8 @@ public class OpenViduProTestAppE2eTest extends AbstractOpenViduTestAppE2eTest {
String body = "{'customSessionId': 'CUSTOM_SESSION_ID'}";
restClient.rest(HttpMethod.POST, "/openvidu/api/sessions", body, HttpStatus.SC_OK);
body = "{'role':'PUBLISHER','record':false}";
JsonObject res = restClient.rest(HttpMethod.POST, "/openvidu/api/sessions/CUSTOM_SESSION_ID/connection", body, HttpStatus.SC_OK);
JsonObject res = restClient.rest(HttpMethod.POST, "/openvidu/api/sessions/CUSTOM_SESSION_ID/connection", body,
HttpStatus.SC_OK);
final String token = res.get("token").getAsString();
final String connectionId = res.get("connectionId").getAsString();
final long createdAt = res.get("createdAt").getAsLong();
@ -208,6 +209,16 @@ public class OpenViduProTestAppE2eTest extends AbstractOpenViduTestAppE2eTest {
restClient.rest(HttpMethod.PATCH, "/openvidu/api/sessions/CUSTOM_SESSION_ID/connection/WRONG",
"{'role':'PUBLISHER','record':true}", HttpStatus.SC_NOT_FOUND);
// No change should return 200. At this point role=PUBLISHER and record=false
restClient.rest(HttpMethod.PATCH, "/openvidu/api/sessions/CUSTOM_SESSION_ID/connection/" + connectionId, "{}",
HttpStatus.SC_OK);
restClient.rest(HttpMethod.PATCH, "/openvidu/api/sessions/CUSTOM_SESSION_ID/connection/" + connectionId,
"{'role':'PUBLISHER'}", HttpStatus.SC_OK);
restClient.rest(HttpMethod.PATCH, "/openvidu/api/sessions/CUSTOM_SESSION_ID/connection/" + connectionId,
"{'record':false}", HttpStatus.SC_OK);
restClient.rest(HttpMethod.PATCH, "/openvidu/api/sessions/CUSTOM_SESSION_ID/connection/" + connectionId,
"{'role':'PUBLISHER','record':false}", HttpStatus.SC_OK);
// Updating only role should let record value untouched
restClient.rest(HttpMethod.PATCH, "/openvidu/api/sessions/CUSTOM_SESSION_ID/connection/" + connectionId,
"{'role':'MODERATOR'}", HttpStatus.SC_OK, true, true, true,
@ -279,9 +290,20 @@ public class OpenViduProTestAppE2eTest extends AbstractOpenViduTestAppE2eTest {
Assert.assertEquals("Wrong role in Connection object", OpenViduRole.SUBSCRIBER, connection.getRole());
Assert.assertFalse("Wrong record in Connection object", connection.record());
/** UPDATE CONNECTION **/
/** UPDATE ACTIVE CONNECTION **/
// Test with REST API
// No change should return 200. At this point role=SUBSCRIBER and record=false
restClient.rest(HttpMethod.PATCH, "/openvidu/api/sessions/CUSTOM_SESSION_ID/connection/" + connectionId, "{}",
HttpStatus.SC_OK);
restClient.rest(HttpMethod.PATCH, "/openvidu/api/sessions/CUSTOM_SESSION_ID/connection/" + connectionId,
"{'role':'SUBSCRIBER'}", HttpStatus.SC_OK);
restClient.rest(HttpMethod.PATCH, "/openvidu/api/sessions/CUSTOM_SESSION_ID/connection/" + connectionId,
"{'record':false}", HttpStatus.SC_OK);
restClient.rest(HttpMethod.PATCH, "/openvidu/api/sessions/CUSTOM_SESSION_ID/connection/" + connectionId,
"{'role':'SUBSCRIBER','record':false}", HttpStatus.SC_OK);
// Updating only role should let record value untouched
restClient.rest(HttpMethod.PATCH, "/openvidu/api/sessions/CUSTOM_SESSION_ID/connection/" + connectionId,
"{'role':'MODERATOR'}", HttpStatus.SC_OK, false, true, true,
@ -291,6 +313,9 @@ public class OpenViduProTestAppE2eTest extends AbstractOpenViduTestAppE2eTest {
+ "','sessionId':'CUSTOM_SESSION_ID','createdAt':" + createdAt + ",'activeAt':"
+ activeAt + ",'serverData':''}",
new String[] { "location", "platform", "clientData" }));
user.getEventManager().waitUntilEventReaches("connectionPropertyChanged", 1);
// Updating only record should let role value untouched
restClient.rest(HttpMethod.PATCH, "/openvidu/api/sessions/CUSTOM_SESSION_ID/connection/" + connectionId,
"{'record':true}", HttpStatus.SC_OK, false, true, true,
@ -300,6 +325,9 @@ public class OpenViduProTestAppE2eTest extends AbstractOpenViduTestAppE2eTest {
+ "','sessionId':'CUSTOM_SESSION_ID','createdAt':" + createdAt + ",'activeAt':"
+ activeAt + ",'serverData':''}",
new String[] { "location", "platform", "clientData" }));
user.getEventManager().waitUntilEventReaches("connectionPropertyChanged", 2);
restClient.rest(HttpMethod.PATCH, "/openvidu/api/sessions/CUSTOM_SESSION_ID/connection/" + connectionId,
"{'role':'SUBSCRIBER','record':true,'data':'OTHER DATA'}", HttpStatus.SC_OK, false, true, true,
mergeJson(DEFAULT_JSON_ACTIVE_CONNECTION,
@ -308,6 +336,9 @@ public class OpenViduProTestAppE2eTest extends AbstractOpenViduTestAppE2eTest {
+ "','sessionId':'CUSTOM_SESSION_ID','createdAt':" + createdAt + ",'activeAt':"
+ activeAt + ",'serverData':''}",
new String[] { "location", "platform", "clientData" }));
user.getEventManager().waitUntilEventReaches("connectionPropertyChanged", 3);
restClient.rest(HttpMethod.PATCH, "/openvidu/api/sessions/CUSTOM_SESSION_ID/connection/" + connectionId,
"{'role':'PUBLISHER'}", HttpStatus.SC_OK, false, true, true,
mergeJson(DEFAULT_JSON_ACTIVE_CONNECTION,
@ -317,6 +348,8 @@ public class OpenViduProTestAppE2eTest extends AbstractOpenViduTestAppE2eTest {
+ activeAt + ",'serverData':''}",
new String[] { "location", "platform", "clientData" }));
user.getEventManager().waitUntilEventReaches("connectionPropertyChanged", 4);
// Test with openvidu-node-client
user.getDriver().findElement(By.id("session-api-btn-0")).click();
Thread.sleep(1000);
@ -333,6 +366,9 @@ public class OpenViduProTestAppE2eTest extends AbstractOpenViduTestAppE2eTest {
user.getDriver().findElement(By.id("update-connection-api-btn")).click();
user.getWaiter().until(ExpectedConditions.attributeToBe(By.id("api-response-text-area"), "value",
"Connection updated: {\"role\":\"SUBSCRIBER\",\"record\":false}"));
user.getEventManager().waitUntilEventReaches("connectionPropertyChanged", 6);
user.getDriver().findElement(By.id("close-dialog-btn")).click();
Thread.sleep(1000);
@ -347,6 +383,9 @@ public class OpenViduProTestAppE2eTest extends AbstractOpenViduTestAppE2eTest {
Assert.assertFalse("Session object should not have changed", session.fetch());
connection = session.updateConnection(connectionId,
new ConnectionProperties.Builder().role(OpenViduRole.PUBLISHER).build());
user.getEventManager().waitUntilEventReaches("connectionPropertyChanged", 7);
Assert.assertFalse("Session object should not have changed", session.fetch());
Assert.assertEquals("Wrong connectionId in Connection object", connectionId, connection.getConnectionId());
Assert.assertEquals("Wrong role in Connection object", OpenViduRole.PUBLISHER, connection.getRole());
@ -354,10 +393,16 @@ public class OpenViduProTestAppE2eTest extends AbstractOpenViduTestAppE2eTest {
Assert.assertEquals("Wrong status in Connection object", "active", connection.getStatus());
connection = session.updateConnection(connectionId,
new ConnectionProperties.Builder().role(OpenViduRole.SUBSCRIBER).build());
user.getEventManager().waitUntilEventReaches("connectionPropertyChanged", 8);
Assert.assertEquals("Wrong role in Connection object", OpenViduRole.SUBSCRIBER, connection.getRole());
Assert.assertFalse("Session object should not have changed", session.fetch());
connection = session.updateConnection(connectionId,
new ConnectionProperties.Builder().role(OpenViduRole.MODERATOR).record(false).data("NO CHANGE").build());
connection = session.updateConnection(connectionId, new ConnectionProperties.Builder()
.role(OpenViduRole.MODERATOR).record(false).data("NO CHANGE").build());
user.getEventManager().waitUntilEventReaches("connectionPropertyChanged", 9);
Assert.assertFalse("Session object should not have changed", session.fetch());
Assert.assertEquals("Wrong role in Connection object", OpenViduRole.MODERATOR, connection.getRole());
Assert.assertFalse("Wrong record in Connection object", connection.record());

View File

@ -6,7 +6,7 @@ import {
import {
OpenVidu, Session, Subscriber, Publisher, Event, StreamEvent, ConnectionEvent,
SessionDisconnectedEvent, SignalEvent, RecordingEvent,
PublisherSpeakingEvent, PublisherProperties, StreamPropertyChangedEvent, OpenViduError
PublisherSpeakingEvent, PublisherProperties, StreamPropertyChangedEvent, ConnectionPropertyChangedEvent, OpenViduError
} from 'openvidu-browser';
import {
OpenVidu as OpenViduAPI,
@ -115,6 +115,7 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
streamCreated: true,
streamDestroyed: true,
streamPropertyChanged: true,
connectionPropertyChanged: true,
recordingStarted: true,
recordingStopped: true,
signal: true,
@ -223,6 +224,7 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
streamCreated: false,
streamDestroyed: false,
streamPropertyChanged: false,
connectionPropertyChanged: false,
recordingStarted: false,
recordingStopped: false,
signal: false,
@ -372,6 +374,15 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
}
}
if (this.sessionEvents.connectionPropertyChanged !== oldValues.connectionPropertyChanged || firstTime) {
this.session.off('connectionPropertyChanged');
if (this.sessionEvents.connectionPropertyChanged) {
this.session.on('connectionPropertyChanged', (event: ConnectionPropertyChangedEvent) => {
this.updateEventList('connectionPropertyChanged', event.changedProperty + ' [' + event.newValue + ']', event);
});
}
}
if (this.sessionEvents.connectionCreated !== oldValues.connectionCreated || firstTime) {
this.session.off('connectionCreated');
if (this.sessionEvents.connectionCreated) {
@ -626,6 +637,7 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
streamCreated: this.sessionEvents.streamCreated,
streamDestroyed: this.sessionEvents.streamDestroyed,
streamPropertyChanged: this.sessionEvents.streamPropertyChanged,
connectionPropertyChanged: this.sessionEvents.connectionPropertyChanged,
recordingStarted: this.sessionEvents.recordingStarted,
recordingStopped: this.sessionEvents.recordingStopped,
signal: this.sessionEvents.signal,
@ -658,6 +670,7 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
streamCreated: result.streamCreated,
streamDestroyed: result.streamDestroyed,
streamPropertyChanged: result.streamPropertyChanged,
connectionPropertyChanged: result.connectionPropertyChanged,
recordingStarted: result.recordingStarted,
recordingStopped: result.recordingStopped,
signal: result.signal,