From e78ee758c5c8263987d2f199c6b9fd1761887975 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= Date: Sun, 13 Feb 2022 23:30:58 +0100 Subject: [PATCH] fix webrtc _connected. --- src/component/internal/webrtc.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/component/internal/webrtc.ts b/src/component/internal/webrtc.ts index 5024184f..56f0f468 100644 --- a/src/component/internal/webrtc.ts +++ b/src/component/internal/webrtc.ts @@ -455,15 +455,13 @@ export class NekoWebRTC extends EventEmitter { } private onDisconnected(error?: Error) { + const wasConnected = this._connected this.disconnect() - if (!this._connected) { - return + if (wasConnected) { + this._log.info(`disconnected`, { error }) + this.emit('disconnected', error) } - - this._log.info(`disconnected`, { error }) - this.emit('disconnected', error) - this._connected = false } private statsEmitter(ms: number = 2000) {