mirror of https://github.com/OpenVidu/openvidu.git
Fix 'on' and 'once' memory leak
parent
b7a36700f9
commit
dd8aeec0dc
|
@ -589,14 +589,7 @@ export class Session implements EventDispatcher {
|
||||||
*/
|
*/
|
||||||
on(type: string, handler: (event: SessionDisconnectedEvent | SignalEvent | StreamEvent | ConnectionEvent | PublisherSpeakingEvent | RecordingEvent) => void): EventDispatcher {
|
on(type: string, handler: (event: SessionDisconnectedEvent | SignalEvent | StreamEvent | ConnectionEvent | PublisherSpeakingEvent | RecordingEvent) => void): EventDispatcher {
|
||||||
|
|
||||||
this.ee.on(type, event => {
|
this.ee.on(type, handler);
|
||||||
if (event) {
|
|
||||||
console.info("Event '" + type + "' triggered by 'Session'", event);
|
|
||||||
} else {
|
|
||||||
console.info("Event '" + type + "' triggered by 'Session'");
|
|
||||||
}
|
|
||||||
handler(event);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (type === 'publisherStartSpeaking') {
|
if (type === 'publisherStartSpeaking') {
|
||||||
this.startSpeakingEventsEnabled = true;
|
this.startSpeakingEventsEnabled = true;
|
||||||
|
@ -628,14 +621,7 @@ export class Session implements EventDispatcher {
|
||||||
*/
|
*/
|
||||||
once(type: string, handler: (event: SessionDisconnectedEvent | SignalEvent | StreamEvent | ConnectionEvent | PublisherSpeakingEvent | RecordingEvent) => void): Session {
|
once(type: string, handler: (event: SessionDisconnectedEvent | SignalEvent | StreamEvent | ConnectionEvent | PublisherSpeakingEvent | RecordingEvent) => void): Session {
|
||||||
|
|
||||||
this.ee.once(type, event => {
|
this.ee.once(type, handler);
|
||||||
if (event) {
|
|
||||||
console.info("Event '" + type + "' triggered once by 'Session'", event);
|
|
||||||
} else {
|
|
||||||
console.info("Event '" + type + "' triggered once by 'Session'");
|
|
||||||
}
|
|
||||||
handler(event);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (type === 'publisherStartSpeaking') {
|
if (type === 'publisherStartSpeaking') {
|
||||||
this.startSpeakingEventsEnabledOnce = true;
|
this.startSpeakingEventsEnabledOnce = true;
|
||||||
|
@ -669,7 +655,7 @@ export class Session implements EventDispatcher {
|
||||||
if (!handler) {
|
if (!handler) {
|
||||||
this.ee.removeAllListeners(type);
|
this.ee.removeAllListeners(type);
|
||||||
} else {
|
} else {
|
||||||
this.ee.off(type, handler);
|
this.ee.removeListener(type, handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type === 'publisherStartSpeaking') {
|
if (type === 'publisherStartSpeaking') {
|
||||||
|
|
|
@ -265,14 +265,7 @@ export class Stream implements EventDispatcher {
|
||||||
* See [[EventDispatcher.on]]
|
* See [[EventDispatcher.on]]
|
||||||
*/
|
*/
|
||||||
on(type: string, handler: (event: Event) => void): EventDispatcher {
|
on(type: string, handler: (event: Event) => void): EventDispatcher {
|
||||||
this.ee.on(type, event => {
|
this.ee.on(type, handler);
|
||||||
if (event) {
|
|
||||||
console.info("Event '" + type + "' triggered by stream '" + this.streamId + "'", event);
|
|
||||||
} else {
|
|
||||||
console.info("Event '" + type + "' triggered by stream '" + this.streamId + "'");
|
|
||||||
}
|
|
||||||
handler(event);
|
|
||||||
});
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,14 +274,7 @@ export class Stream implements EventDispatcher {
|
||||||
* See [[EventDispatcher.once]]
|
* See [[EventDispatcher.once]]
|
||||||
*/
|
*/
|
||||||
once(type: string, handler: (event: Event) => void): EventDispatcher {
|
once(type: string, handler: (event: Event) => void): EventDispatcher {
|
||||||
this.ee.once(type, event => {
|
this.ee.once(type, handler);
|
||||||
if (event) {
|
|
||||||
console.info("Event '" + type + "' triggered once by stream '" + this.streamId + "'", event);
|
|
||||||
} else {
|
|
||||||
console.info("Event '" + type + "' triggered once by stream '" + this.streamId + "'");
|
|
||||||
}
|
|
||||||
handler(event);
|
|
||||||
});
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -149,14 +149,7 @@ export class StreamManager implements EventDispatcher {
|
||||||
* See [[EventDispatcher.on]]
|
* See [[EventDispatcher.on]]
|
||||||
*/
|
*/
|
||||||
on(type: string, handler: (event: Event) => void): EventDispatcher {
|
on(type: string, handler: (event: Event) => void): EventDispatcher {
|
||||||
this.ee.on(type, event => {
|
this.ee.on(type, handler);
|
||||||
if (event) {
|
|
||||||
console.info("Event '" + type + "' triggered by '" + (this.remote ? 'Subscriber' : 'Publisher') + "'", event);
|
|
||||||
} else {
|
|
||||||
console.info("Event '" + type + "' triggered by '" + (this.remote ? 'Subscriber' : 'Publisher') + "'");
|
|
||||||
}
|
|
||||||
handler(event);
|
|
||||||
});
|
|
||||||
if (type === 'videoElementCreated') {
|
if (type === 'videoElementCreated') {
|
||||||
if (!!this.stream && this.lazyLaunchVideoElementCreatedEvent) {
|
if (!!this.stream && this.lazyLaunchVideoElementCreatedEvent) {
|
||||||
this.ee.emitEvent('videoElementCreated', [new VideoElementEvent(this.videos[0].video, this, 'videoElementCreated')]);
|
this.ee.emitEvent('videoElementCreated', [new VideoElementEvent(this.videos[0].video, this, 'videoElementCreated')]);
|
||||||
|
@ -183,14 +176,7 @@ export class StreamManager implements EventDispatcher {
|
||||||
* See [[EventDispatcher.once]]
|
* See [[EventDispatcher.once]]
|
||||||
*/
|
*/
|
||||||
once(type: string, handler: (event: Event) => void): StreamManager {
|
once(type: string, handler: (event: Event) => void): StreamManager {
|
||||||
this.ee.once(type, event => {
|
this.ee.once(type, handler);
|
||||||
if (event) {
|
|
||||||
console.info("Event '" + type + "' triggered once by '" + (this.remote ? 'Subscriber' : 'Publisher') + "'", event);
|
|
||||||
} else {
|
|
||||||
console.info("Event '" + type + "' triggered once by '" + (this.remote ? 'Subscriber' : 'Publisher') + "'");
|
|
||||||
}
|
|
||||||
handler(event);
|
|
||||||
});
|
|
||||||
if (type === 'videoElementCreated') {
|
if (type === 'videoElementCreated') {
|
||||||
if (!!this.stream && this.lazyLaunchVideoElementCreatedEvent) {
|
if (!!this.stream && this.lazyLaunchVideoElementCreatedEvent) {
|
||||||
this.ee.emitEvent('videoElementCreated', [new VideoElementEvent(this.videos[0].video, this, 'videoElementCreated')]);
|
this.ee.emitEvent('videoElementCreated', [new VideoElementEvent(this.videos[0].video, this, 'videoElementCreated')]);
|
||||||
|
|
Loading…
Reference in New Issue