openvidu-browser: force filter operations for moderators

pull/108/merge
pabloFuente 2018-08-28 17:44:03 +02:00
parent 86f50bdeaf
commit b9f51ab40a
2 changed files with 55 additions and 47 deletions

View File

@ -137,7 +137,7 @@ export class Filter {
console.info('Adding filter event listener to event ' + eventType + ' to stream ' + this.stream.streamId); console.info('Adding filter event listener to event ' + eventType + ' to stream ' + this.stream.streamId);
this.stream.session.openvidu.sendRequest( this.stream.session.openvidu.sendRequest(
'addFilterEventListener', 'addFilterEventListener',
{ streamId: this.stream.streamId, type: eventType }, { streamId: this.stream.streamId, eventType },
(error, response) => { (error, response) => {
if (error) { if (error) {
console.error('Error adding filter event listener to event ' + eventType + 'for Stream ' + this.stream.streamId, error); console.error('Error adding filter event listener to event ' + eventType + 'for Stream ' + this.stream.streamId, error);
@ -169,7 +169,7 @@ export class Filter {
console.info('Removing filter event listener to event ' + eventType + ' to stream ' + this.stream.streamId); console.info('Removing filter event listener to event ' + eventType + ' to stream ' + this.stream.streamId);
this.stream.session.openvidu.sendRequest( this.stream.session.openvidu.sendRequest(
'removeFilterEventListener', 'removeFilterEventListener',
{ streamId: this.stream.streamId, type: eventType }, { streamId: this.stream.streamId, eventType },
(error, response) => { (error, response) => {
if (error) { if (error) {
console.error('Error removing filter event listener to event ' + eventType + 'for Stream ' + this.stream.streamId, error); console.error('Error removing filter event listener to event ' + eventType + 'for Stream ' + this.stream.streamId, error);

View File

@ -771,10 +771,8 @@ export class Session implements EventDispatcher {
* @hidden * @hidden
*/ */
onStreamPropertyChanged(msg): void { onStreamPropertyChanged(msg): void {
this.getRemoteConnection(msg.connectionId, 'Remote connection ' + msg.connectionId + " unknown when 'onStreamPropertyChanged'. " +
'Existing remote connections: ' + JSON.stringify(Object.keys(this.remoteConnections)))
.then(connection => { const callback = (connection: Connection) => {
if (!!connection.stream && connection.stream.streamId === msg.streamId) { if (!!connection.stream && connection.stream.streamId === msg.streamId) {
const stream = connection.stream; const stream = connection.stream;
let oldValue; let oldValue;
@ -809,17 +807,27 @@ export class Session implements EventDispatcher {
msg.newValue = stream.filter; msg.newValue = stream.filter;
break; break;
} }
this.ee.emitEvent('streamPropertyChanged', [new StreamPropertyChangedEvent(this, stream, msg.property, msg.newValue, oldValue, msg.reason)]); this.ee.emitEvent('streamPropertyChanged', [new StreamPropertyChangedEvent(this, stream, msg.property, msg.newValue, oldValue, msg.reason)]);
stream.streamManager.emitEvent('streamPropertyChanged', [new StreamPropertyChangedEvent(stream.streamManager, stream, msg.property, msg.newValue, oldValue, msg.reason)]); stream.streamManager.emitEvent('streamPropertyChanged', [new StreamPropertyChangedEvent(stream.streamManager, stream, msg.property, msg.newValue, oldValue, msg.reason)]);
} else { } else {
console.error("No stream with streamId '" + msg.streamId + "' found for connection '" + msg.connectionId + "' on 'streamPropertyChanged' event"); console.error("No stream with streamId '" + msg.streamId + "' found for connection '" + msg.connectionId + "' on 'streamPropertyChanged' event");
} }
};
if (msg.connectionId === this.connection.connectionId) {
// Your stream has been forcedly changed (filter feature)
callback(this.connection);
} else {
this.getRemoteConnection(msg.connectionId, 'Remote connection ' + msg.connectionId + " unknown when 'onStreamPropertyChanged'. " +
'Existing remote connections: ' + JSON.stringify(Object.keys(this.remoteConnections)))
.then(connection => {
callback(connection);
}) })
.catch(openViduError => { .catch(openViduError => {
console.error(openViduError); console.error(openViduError);
}); });
} }
}
/** /**
* @hidden * @hidden