Merge pull request #668 from JamieRez/master

Bye.js Fix
This commit is contained in:
Mark Nadal 2018-12-20 15:32:45 -08:00 committed by GitHub
commit 547adab000
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 18 deletions

1
gun.js
View File

@ -1982,6 +1982,7 @@
} }
return; return;
} }
ctx.on('in', msg); ctx.on('in', msg);
return; return;

View File

@ -3,10 +3,10 @@ var Gun = (typeof window !== "undefined")? window.Gun : require('../gun');
Gun.on('opt', function(root){ Gun.on('opt', function(root){
this.to.next(root); this.to.next(root);
if(root.once){ return } if(root.once){ return }
console.log("WARNING: `lib/bye` is out of date!");
root.on('in', function(msg){ root.on('in', function(msg){
if(!msg.peer || !msg.BYE){ return this.to.next(msg) } //Msg did not have a peer property saved before, so nothing ever went further
var peer = msg.peer(); if(!msg.mesh || !msg.BYE){ return this.to.next(msg) }
var peer = msg.mesh.via;
(peer.bye = peer.bye || []).push(msg.BYE); (peer.bye = peer.bye || []).push(msg.BYE);
}) })
root.on('bye', function(peer){ root.on('bye', function(peer){