From afb965dc9c1b43ab3a6881c48b314a0cf02a73e8 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Thu, 10 Oct 2024 14:51:39 +0800 Subject: [PATCH] bugfix --- bricks/rtc.js | 11 +++++++++++ bricks/utils.js | 7 ++++--- bricks/video.js | 1 + 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/bricks/rtc.js b/bricks/rtc.js index b226ffd..af4b1e2 100644 --- a/bricks/rtc.js +++ b/bricks/rtc.js @@ -32,6 +32,7 @@ bricks.Signaling = class { this.handlers = {}; this.sessionhandlers = {}; this.init_websocket(); + this.hb_task = null; } init_websocket(){ @@ -43,6 +44,13 @@ bricks.Signaling = class { } reconnect(){ console.log('eror happened'); + if (this.hb_task){ + this.hb_task.cancel(); + this.hb_task = null; + } + if (this.onclose){ + this.onclose(); + } return; try { this.socket.close(); @@ -122,6 +130,9 @@ bricks.Signaling = class { type:'login', } this.send_data(d); + if (this.heartbeat_period){ + this.hb_task = schedule_once(this.login.bind(this), this.heartbeat_period); + } } logout(){ diff --git a/bricks/utils.js b/bricks/utils.js index b1e9fd2..0e0b393 100755 --- a/bricks/utils.js +++ b/bricks/utils.js @@ -108,15 +108,16 @@ var schedule_once = function(f, t){ t:time in second unit */ t = t * 1000 - window.setTimeout(f, t); + return window.setTimeout(f, t); } var schedule_interval = function(f, t){ var mf = function(func, t){ + console.log('arguments:', func, t); func(); - schedule_once(f, t); + return schedule_once(mf.bind(func, t), t); } - schedule_once(mf.bind(f,t), t); + return schedule_once(mf.bind(f,t), t); } var debug = function(){ diff --git a/bricks/video.js b/bricks/video.js index c54eda0..1fe2cfc 100755 --- a/bricks/video.js +++ b/bricks/video.js @@ -41,6 +41,7 @@ bricks.Video = class extends bricks.Layout { this.hidedbtn.hide(); this.add_widget(this.hidedbtn); } + destroy_resource(params, event){ var w = event.target.bricks_widget; if (! w.parent){