mirror of https://github.com/OpenVidu/openvidu.git
'sessionDisconnected' event emitted by Session (preventDefault() defined)
parent
3422b0f474
commit
850dab186b
File diff suppressed because one or more lines are too long
|
@ -3,7 +3,7 @@ import { Stream } from '../OpenViduInternal/Stream';
|
||||||
import { Connection } from "../OpenViduInternal/Connection";
|
import { Connection } from "../OpenViduInternal/Connection";
|
||||||
|
|
||||||
import { OpenVidu } from './OpenVidu';
|
import { OpenVidu } from './OpenVidu';
|
||||||
import { Publisher} from './Publisher';
|
import { Publisher } from './Publisher';
|
||||||
import { Subscriber } from './Subscriber';
|
import { Subscriber } from './Subscriber';
|
||||||
|
|
||||||
import EventEmitter = require('wolfy87-eventemitter');
|
import EventEmitter = require('wolfy87-eventemitter');
|
||||||
|
@ -24,6 +24,17 @@ export class Session {
|
||||||
event.stream.removeVideo();
|
event.stream.removeVideo();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Listens to the deactivation of the default behaviour upon the disconnection of a Session
|
||||||
|
this.session.addEventListener('session-disconnected-default', () => {
|
||||||
|
let s: Stream;
|
||||||
|
for (s of this.openVidu.openVidu.getRemoteStreams()) {
|
||||||
|
s.removeVideo();
|
||||||
|
}
|
||||||
|
for (let streamId in this.connection.getStreams()) {
|
||||||
|
this.connection.getStreams()[streamId].removeVideo();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Sets or updates the value of 'connection' property. Triggered by SessionInternal when succesful connection
|
// Sets or updates the value of 'connection' property. Triggered by SessionInternal when succesful connection
|
||||||
this.session.addEventListener('update-connection-object', event => {
|
this.session.addEventListener('update-connection-object', event => {
|
||||||
this.connection = event.connection;
|
this.connection = event.connection;
|
||||||
|
@ -31,7 +42,7 @@ export class Session {
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(token: string, callback: any);
|
connect(token: string, callback: any);
|
||||||
connect(token:string, metadata: string, callback: any);
|
connect(token: string, metadata: string, callback: any);
|
||||||
|
|
||||||
connect(param1, param2, param3?) {
|
connect(param1, param2, param3?) {
|
||||||
// Early configuration to deactivate automatic subscription to streams
|
// Early configuration to deactivate automatic subscription to streams
|
||||||
|
@ -56,13 +67,10 @@ export class Session {
|
||||||
|
|
||||||
disconnect() {
|
disconnect() {
|
||||||
this.openVidu.openVidu.close(false);
|
this.openVidu.openVidu.close(false);
|
||||||
let s: Stream;
|
this.session.emitEvent('sessionDisconnected', [{
|
||||||
for (s of this.openVidu.openVidu.getRemoteStreams()){
|
preventDefault: () => { this.session.removeEvent('session-disconnected-default'); }
|
||||||
s.removeVideo();
|
}]);
|
||||||
}
|
this.session.emitEvent('session-disconnected-default', [{}]);
|
||||||
for (let streamId in this.connection.getStreams()) {
|
|
||||||
this.connection.getStreams()[streamId].removeVideo();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
publish(publisher: Publisher) {
|
publish(publisher: Publisher) {
|
||||||
|
|
|
@ -177,6 +177,10 @@ export class SessionInternal {
|
||||||
this.ee.off(eventName, listener);
|
this.ee.off(eventName, listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
removeEvent(eventName){
|
||||||
|
this.ee.removeEvent(eventName);
|
||||||
|
}
|
||||||
|
|
||||||
emitEvent(eventName, eventsArray) {
|
emitEvent(eventName, eventsArray) {
|
||||||
this.ee.emitEvent(eventName, eventsArray);
|
this.ee.emitEvent(eventName, eventsArray);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue