mirror of
https://github.com/amark/gun.git
synced 2025-03-30 15:08:33 +00:00

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.
41 lines
847 B
HTML
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>
|