This commit is contained in:
yumoqing 2024-10-10 14:51:39 +08:00
parent 48314a0bd1
commit afb965dc9c
3 changed files with 16 additions and 3 deletions

View File

@ -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(){

View File

@ -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(){

View File

@ -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){