From 6ab4daddcab3eb56245cb5d43479e20c5fc67465 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Wed, 21 Aug 2024 10:39:54 +0800 Subject: [PATCH] bugfix --- bricks/rtc.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/bricks/rtc.js b/bricks/rtc.js index 86a6eff..14ef1e0 100644 --- a/bricks/rtc.js +++ b/bricks/rtc.js @@ -259,9 +259,6 @@ bricks.RTCClient = class extends bricks.VBox { // 创建 PeerConnection async createPeerConnection(to_info) { this.phone.set_state('using'); - if (this.role == 'requester'){ - await this.send_offer(); - } const configuration = { iceServers: [ { urls: this.ice_url }, @@ -276,6 +273,13 @@ bricks.RTCClient = class extends bricks.VBox { .forEach(track => { this.peerConnection.addTrack(track, this.localVideo.stream); }); + if (this.peerConnection){ + console.log('peerConnection is null'); + return; + } + if (this.role == 'requester'){ + await this.send_offer(); + } // 处理 ICE 候选 this.peerConnection.onicecandidate = this.send_candidate.bind(this, to_info);