From bf0ad6257593e39b14328a2fb6041ca8bb4971bc Mon Sep 17 00:00:00 2001 From: Tom Sightler Date: Sun, 13 Oct 2024 21:18:22 -0400 Subject: [PATCH] Handle iceCandidate event with no candidate iceCandidate event with no candidate means all candidates are gathered. --- .../streaming/webrtc-connection.ts | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/packages/ring-client-api/streaming/webrtc-connection.ts b/packages/ring-client-api/streaming/webrtc-connection.ts index 5a238024..46b9ff75 100644 --- a/packages/ring-client-api/streaming/webrtc-connection.ts +++ b/packages/ring-client-api/streaming/webrtc-connection.ts @@ -132,16 +132,18 @@ export class WebrtcConnection extends Subscribed { }), this.pc.onIceCandidate.subscribe(async (iceCandidate) => { - await firstValueFrom(this.onOfferSent) - this.sendMessage({ - method: 'ice', - dialog_id: this.dialogId, - body: { - doorbot_id: camera.id, - ice: iceCandidate.candidate, - mlineindex: iceCandidate.sdpMLineIndex, - }, - }) + if (iceCandidate?.candidate) { + await firstValueFrom(this.onOfferSent) + this.sendMessage({ + method: 'ice', + dialog_id: this.dialogId, + body: { + doorbot_id: camera.id, + ice: iceCandidate.candidate, + mlineindex: iceCandidate.sdpMLineIndex, + }, + }) + } }), ) }