mirror of
https://github.com/amark/gun.git
synced 2025-06-05 13:46:43 +00:00
Update bye.js
This commit is contained in:
parent
14f6ba098a
commit
93cd24caa7
24
lib/bye.js
24
lib/bye.js
@ -1,24 +1,22 @@
|
|||||||
var Gun = (typeof window !== "undefined")? window.Gun : require('../gun');
|
var Gun = (typeof window !== "undefined")? window.Gun : require('../gun');
|
||||||
|
|
||||||
Gun.on('opt', function(root){
|
Gun.on('create', function(root){
|
||||||
this.to.next(root);
|
this.to.next(root);
|
||||||
if(root.once){ return }
|
var mesh = root.opt.mesh;
|
||||||
root.on('in', function(msg){
|
if(!mesh){ return }
|
||||||
//Msg did not have a peer property saved before, so nothing ever went further
|
mesh.hear['bye'] = function(msg, peer){
|
||||||
if(!msg._ || !msg.BYE){ return this.to.next(msg) }
|
(peer.byes = peer.byes || []).push(msg.bye);
|
||||||
var peer = msg._.via;
|
}
|
||||||
(peer.bye = peer.bye || []).push(msg.BYE);
|
|
||||||
})
|
|
||||||
root.on('bye', function(peer){
|
root.on('bye', function(peer){
|
||||||
this.to.next(peer);
|
this.to.next(peer);
|
||||||
if(!peer.bye){ return }
|
if(!peer.byes){ return }
|
||||||
var gun = root.gun;
|
var gun = root.$;
|
||||||
Gun.obj.map(peer.bye, function(data){
|
Gun.obj.map(peer.byes, function(data){
|
||||||
Gun.obj.map(data, function(put, soul){
|
Gun.obj.map(data, function(put, soul){
|
||||||
gun.get(soul).put(put);
|
gun.get(soul).put(put);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
peer.bye = [];
|
peer.byes = [];
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -30,7 +28,7 @@ Gun.chain.bye = function(){
|
|||||||
var tmp = data;
|
var tmp = data;
|
||||||
(data = {})[at.get] = tmp;
|
(data = {})[at.get] = tmp;
|
||||||
});
|
});
|
||||||
root.on('out', {BYE: data});
|
root.on('out', {bye: data});
|
||||||
return gun;
|
return gun;
|
||||||
}
|
}
|
||||||
return bye;
|
return bye;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user