From 45e8ad19a9cd0b82063d8cecaaf2ba5efc5c2070 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= Date: Thu, 10 Mar 2022 22:39:34 +0100 Subject: [PATCH] webrtc send: check only data channel availability. --- src/component/internal/webrtc.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/component/internal/webrtc.ts b/src/component/internal/webrtc.ts index e4e3a3de..f2d43f0d 100644 --- a/src/component/internal/webrtc.ts +++ b/src/component/internal/webrtc.ts @@ -328,8 +328,8 @@ export class NekoWebRTC extends EventEmitter { public send(event: 'wheel' | 'mousemove', data: { x: number; y: number }): void public send(event: 'mousedown' | 'mouseup' | 'keydown' | 'keyup', data: { key: number }): void public send(event: string, data: any): void { - if (!this.connected) { - this._log.warn(`attempting to send data while disconnected`, { event }) + if (typeof this._channel === 'undefined' || this._channel.readyState !== 'open') { + this._log.warn(`attempting to send data, but data-channel is not open`, { event }) return } @@ -385,7 +385,7 @@ export class NekoWebRTC extends EventEmitter { return } - this._channel!.send(buffer) + this._channel.send(buffer) } private onTrack(event: RTCTrackEvent) {