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) {