gun/examples/axe.html
Adriano Rogowski 680b2d115a AXE - peer/soul subscribe. In this version the peers receive only data subscribed with gun.get(...soul...).once(...)
TODO:
 1) if the peer change the id, will lost the subscribes. Workaround for this is set the pid (unique) in: Gun(pid: 'mypeerid', peers:[...])
 2) If the superpeer die, the subscribes will be lost. Each peer must resubscribe all souls.
2018-11-21 19:28:28 -02:00

41 lines
847 B
HTML

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0" />
<title>Testing AXE</title>
</head>
<body>
<script src="../gun.js"></script>
<!-- <script src="../axe.js"></script> -->
<!-- <script src="../sea.js"></script> -->
<script>
var pid = location.hash.slice(1);
var opt = ({
peers: [`${location.origin}/gun`]
});
if (pid) { opt.pid = pid; }
Gun.on('opt', function(ctx) {
this.to.next(ctx);
ctx.on('hi', function(opt) {
console.log('HI!! PEER', new Date(), opt.pid);
});
if (pid) {
ctx.on('out', function(msg) {
msg.pid = pid;
this.to.next(msg);
});
}
});
var gun = Gun(opt);
//var user = gun.user();
</script>
</body>
</html>