From e61b04671b0df14ce6b741b20960b6413651e3da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= Date: Thu, 10 Mar 2022 22:39:55 +0100 Subject: [PATCH] fix onsignalingstatechange. --- src/component/internal/webrtc.ts | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/component/internal/webrtc.ts b/src/component/internal/webrtc.ts index f2d43f0d..ec31345d 100644 --- a/src/component/internal/webrtc.ts +++ b/src/component/internal/webrtc.ts @@ -133,7 +133,7 @@ export class NekoWebRTC extends EventEmitter { } this._state = this._peer.iceConnectionState - this._log.info(`peer ice connection state changed`, { state: this._state }) + this._log.info(`ice connection state changed`, { state: this._state }) switch (this._state) { case 'connected': @@ -162,19 +162,13 @@ export class NekoWebRTC extends EventEmitter { return } - const state = this._peer.iceConnectionState - this._log.info(`peer signaling state changed`, { state }) + const state = this._peer.signalingState + this._log.info(`signaling state changed`, { state }) - switch (state) { - case 'connected': - this.onConnected() - break - // The closed signaling state has been deprecated in favor of the closed iceConnectionState. - // We are watching for it here to add a bit of backward compatibility. - case 'closed': - case 'failed': - this.onDisconnected(new Error('peer ' + state)) - break + // The closed signaling state has been deprecated in favor of the closed iceConnectionState. + // We are watching for it here to add a bit of backward compatibility. + if (state == 'closed') { + this.onDisconnected(new Error('signaling state changed to closed')) } }