From 42588ac51a1cd1dafb5d24cc097801587ac13e4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= Date: Wed, 16 Jun 2021 23:09:34 +0200 Subject: [PATCH] _candidates as private. --- src/component/internal/webrtc.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/component/internal/webrtc.ts b/src/component/internal/webrtc.ts index 86cbe166..a73f7fe8 100644 --- a/src/component/internal/webrtc.ts +++ b/src/component/internal/webrtc.ts @@ -39,6 +39,7 @@ export class NekoWebRTC extends EventEmitter { private _peer?: RTCPeerConnection private _channel?: RTCDataChannel private _state: RTCIceConnectionState = 'disconnected' + private _candidates: RTCIceCandidateInit[] = [] private _log: Logger private _statsStop?: () => void @@ -61,10 +62,9 @@ export class NekoWebRTC extends EventEmitter { ) } - candidates: RTCIceCandidateInit[] = [] public async setCandidate(candidate: RTCIceCandidateInit) { if (!this._peer) { - this.candidates.push(candidate) + this._candidates.push(candidate) return } @@ -133,13 +133,13 @@ export class NekoWebRTC extends EventEmitter { this._peer.addTransceiver('video', { direction: 'recvonly' }) this._peer.setRemoteDescription({ type: 'offer', sdp }) - if (this.candidates.length > 0) { - for (const candidate of this.candidates) { + if (this._candidates.length > 0) { + for (const candidate of this._candidates) { this._peer.addIceCandidate(candidate) } - this._log.debug(`added ${this.candidates.length} remote ICE candidates`, this.candidates) - this.candidates = [] + this._log.debug(`added ${this._candidates.length} remote ICE candidates`, this._candidates) + this._candidates = [] } const answer = await this._peer.createAnswer()