mirror of
https://github.com/amark/gun.git
synced 2025-03-30 15:08:33 +00:00
AXE - chancher lib/super.js to use Rad instead of json plain object.
This commit is contained in:
parent
f92da9b14d
commit
f7a5937ed5
19
lib/super.js
19
lib/super.js
@ -2,7 +2,7 @@
|
||||
var Gun = (typeof window !== "undefined")? window.Gun : require('../gun');
|
||||
var Rad = (Gun.window||{}).Radix || require('./radix');
|
||||
/// Store the subscribes
|
||||
Gun.subscribe = {}; /// TODO: use Rad instead of plain object?
|
||||
Gun.subs = Rad();
|
||||
function input(msg){
|
||||
var at = this.as, to = this.to, peer = (msg._||empty).via;
|
||||
var get = msg.get, soul, key;
|
||||
@ -14,11 +14,20 @@
|
||||
} else {
|
||||
|
||||
}
|
||||
if (!peer.id) {console.log('[WARN] no peer.id %s', soul);}
|
||||
Gun.subscribe[soul] = Gun.subscribe[soul] || [];
|
||||
if (Gun.subscribe[soul].indexOf(peer) === -1) {
|
||||
Gun.subscribe[soul].push(peer);
|
||||
if (!peer.id) {console.log('[*** WARN] no peer.id %s', soul);}
|
||||
var subs = Gun.subs(soul) || null;
|
||||
var tmp = subs ? subs.split(',') : [], p = at.opt.peers;
|
||||
if (subs) {
|
||||
Gun.obj.map(subs.split(','), function(peerid) {
|
||||
if (peerid in p) { tmp.push(peerid); }
|
||||
});
|
||||
}
|
||||
if (tmp.indexOf(peer.id) === -1) { tmp.push(peer.id);}
|
||||
tmp = tmp.join(',');
|
||||
Gun.subs(soul, tmp);
|
||||
var dht = {};
|
||||
dht[soul] = tmp;
|
||||
at.opt.mesh.say({dht:dht}, peer);
|
||||
}
|
||||
to.next(msg);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user