pinokiod 3.8.113 → 3.8.115
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/kernel/peer.js +8 -4
- package/package.json +1 -1
package/kernel/peer.js
CHANGED
|
@@ -10,7 +10,6 @@ class PeerDiscovery {
|
|
|
10
10
|
this.peers = new Set();
|
|
11
11
|
this.host = this._getLocalIPAddress()
|
|
12
12
|
this.default_port = 42000
|
|
13
|
-
this.socket = dgram.createSocket('udp4');
|
|
14
13
|
// this.start();
|
|
15
14
|
}
|
|
16
15
|
stop() {
|
|
@@ -38,7 +37,7 @@ class PeerDiscovery {
|
|
|
38
37
|
if (this.active) {
|
|
39
38
|
// Listen for incoming pings
|
|
40
39
|
console.log("kernel.peer start")
|
|
41
|
-
|
|
40
|
+
this.socket = dgram.createSocket('udp4');
|
|
42
41
|
this.socket.on('message', (msg, rinfo) => {
|
|
43
42
|
console.log("peer message", { msg, rinfo })
|
|
44
43
|
const ip = rinfo.address;
|
|
@@ -59,14 +58,19 @@ class PeerDiscovery {
|
|
|
59
58
|
console.log("binding socket")
|
|
60
59
|
this.socket.bind({ address: "0.0.0.0", port: this.port }, () => {
|
|
61
60
|
console.log("socket bound")
|
|
62
|
-
this.socket.setMulticastLoopback(true);
|
|
61
|
+
// this.socket.setMulticastLoopback(true);
|
|
63
62
|
|
|
64
63
|
this.socket.setBroadcast(true);
|
|
65
64
|
|
|
66
65
|
// Send broadcast pings every interval
|
|
67
66
|
this.interval_handle = setInterval(() => {
|
|
68
67
|
console.log("send message to peers")
|
|
69
|
-
this.socket.send(this.message, 0, this.message.length, this.port, '
|
|
68
|
+
//this.socket.send(this.message, 0, this.message.length, this.port, '127.0.0.1');
|
|
69
|
+
//console.log("sent to 127.0.0.1")
|
|
70
|
+
//this.socket.send(this.message, 0, this.message.length, this.port, '255.255.255.255');
|
|
71
|
+
this.socket.send(this.message, 0, this.message.length, this.port, '192.168.1.255');
|
|
72
|
+
//console.log("sent to 255.255.255.255")
|
|
73
|
+
console.log("sent message")
|
|
70
74
|
}, this.interval);
|
|
71
75
|
});
|
|
72
76
|
}
|