This commit is contained in:
yumoqing 2024-10-10 16:41:27 +08:00
parent 3594dd3161
commit cb6cea0487

View File

@ -21,6 +21,8 @@ bricks.Signaling = class {
signaling_url:
info:
connect_opts:
onclose:
onpeers
}
*/
constructor(opts){
@ -33,6 +35,10 @@ bricks.Signaling = class {
this.sessionhandlers = {};
this.init_websocket();
this.hb_task = null;
this.heartbeat_period = opts.heartbeat_period;
this.onclose = opts.onclose;
this.onopen = opts.onopen;
this.onpeers = opts.onpeers;
if (!this.heartbeat_period){
this.heartbeat_period = 0;
}
@ -90,11 +96,13 @@ bricks.Signaling = class {
async recvdata_handler(data){
if (data.type == 'online'){
data.online.forEach(p => {
var d = self.peers[p.id];
var d = this.peers[p.id];
if (!d) d = {};
d = bricks.extend(d, p);
self.peers[p.id] = d;
})
this.peers[p.id] = d;
});
if (this.onpeers){
this.onpeers(this.peers);
return;
}
if (data.type == 'new_session'){