mirror of
https://github.com/amark/gun.git
synced 2025-11-23 22:15:55 +00:00
multicast
This commit is contained in:
parent
52b787a1ed
commit
ff8b0177e4
@ -47,6 +47,7 @@ Gun.on('create', function(root){
|
|||||||
}
|
}
|
||||||
|
|
||||||
socket.on("message", function(message, rinfo) {
|
socket.on("message", function(message, rinfo) {
|
||||||
|
try {
|
||||||
var msgObj = JSON.parse(message.toString(ENC));
|
var msgObj = JSON.parse(message.toString(ENC));
|
||||||
if (!(msgObj.gun && msgObj.gun.port)) { return }
|
if (!(msgObj.gun && msgObj.gun.port)) { return }
|
||||||
var peer = `http://${rinfo.address}:${msgObj.gun.port}`;
|
var peer = `http://${rinfo.address}:${msgObj.gun.port}`;
|
||||||
@ -54,5 +55,8 @@ Gun.on('create', function(root){
|
|||||||
console.log(`peer ${peer} found via multicast`);
|
console.log(`peer ${peer} found via multicast`);
|
||||||
root.$.opt({peers: [peer]});
|
root.$.opt({peers: [peer]});
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
|
// console.error(`Received multicast from ${rinfo.address}:${rinfo.port} but failed to connect:`, e);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user