webrtc send: check only data channel availability.

This commit is contained in:
Miroslav Šedivý 2022-03-10 22:39:34 +01:00
parent f536552377
commit 45e8ad19a9

View File

@ -328,8 +328,8 @@ export class NekoWebRTC extends EventEmitter<NekoWebRTCEvents> {
public send(event: 'wheel' | 'mousemove', data: { x: number; y: number }): void 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: 'mousedown' | 'mouseup' | 'keydown' | 'keyup', data: { key: number }): void
public send(event: string, data: any): void { public send(event: string, data: any): void {
if (!this.connected) { if (typeof this._channel === 'undefined' || this._channel.readyState !== 'open') {
this._log.warn(`attempting to send data while disconnected`, { event }) this._log.warn(`attempting to send data, but data-channel is not open`, { event })
return return
} }
@ -385,7 +385,7 @@ export class NekoWebRTC extends EventEmitter<NekoWebRTCEvents> {
return return
} }
this._channel!.send(buffer) this._channel.send(buffer)
} }
private onTrack(event: RTCTrackEvent) { private onTrack(event: RTCTrackEvent) {