Nikolay Suslov 4 tahun lalu
induk
melakukan
bfcad0a548
3 mengubah file dengan 34 tambahan dan 9 penghapusan
  1. 27 2
      index.js
  2. 6 6
      package-lock.json
  3. 1 1
      package.json

+ 27 - 2
index.js

@@ -8,6 +8,7 @@ require('gun/sea')
 require('gun/lib/path')
 require('gun/lib/not')
 require('gun/nts')
+require('gun/lib/bye')
 
 config.readConfigFile();
 var conf = config.parseConfigOptions();
@@ -22,5 +23,29 @@ if (conf.ssl) {
     config.server = require('http').createServer(Gun.serve(__dirname));
 }
 
-global.gun = Gun({ web: config.server.listen(config.port), axe: false }); //until: 5000, chunk: 10
-console.log('Relay peer started on port ' + config.port + ' with /gun');
+global.gun = Gun({ web: config.server.listen(config.port), axe: false}); //until: 5000, chunk: 10 
+console.log('Relay peer started on port ' + config.port + ' with /gun');
+
+let tickMsg = {
+    parameters: [],
+    time: 'tick'//hb
+};
+
+global.gun.get('server').get('heartbeat').get('tick').put(JSON.stringify(tickMsg));
+
+//instance.get('heartbeat').put({ tick: "{}" }).heartbeat(0.0, 1);
+
+setInterval(function () {
+
+    let message = {
+        parameters: [],
+        time: 'tick'//hb
+    };
+
+    global.gun.get('server').get('heartbeat').get('tick').put(JSON.stringify(message),function(ack){
+        if(ack.err){ 
+            console.log('ERROR: ' + ack.err)
+             
+        }});
+
+}, 50); //FIX ERR: syncing c

+ 6 - 6
package-lock.json

@@ -38,9 +38,9 @@
       }
     },
     "@types/node": {
-      "version": "10.14.18",
-      "resolved": "https://registry.npmjs.org/@types/node/-/node-10.14.18.tgz",
-      "integrity": "sha512-ryO3Q3++yZC/+b8j8BdKd/dn9JlzlHBPdm80656xwYUdmPkpTGTjkAdt6BByiNupGPE8w0FhBgvYy/fX9hRNGQ==",
+      "version": "10.14.19",
+      "resolved": "https://registry.npmjs.org/@types/node/-/node-10.14.19.tgz",
+      "integrity": "sha512-j6Sqt38ssdMKutXBUuAcmWF8QtHW1Fwz/mz4Y+Wd9mzpBiVFirjpNQf363hG5itkG+yGaD+oiLyb50HxJ36l9Q==",
       "optional": true
     },
     "addressparser": {
@@ -91,9 +91,9 @@
       }
     },
     "gun": {
-      "version": "0.2019.915",
-      "resolved": "https://registry.npmjs.org/gun/-/gun-0.2019.915.tgz",
-      "integrity": "sha512-9nZFLZX0USkt7Li1SzzyCsez6R486mnXdwvSzZaUc2yLuLuY/ulm0V9vb7V8Yu+IRnMHuyT0XnBbum0/Vs2Q4g==",
+      "version": "0.2019.930",
+      "resolved": "https://registry.npmjs.org/gun/-/gun-0.2019.930.tgz",
+      "integrity": "sha512-JZunmIcZqwq9MgrMHBRVAB7HbgNWUnwnHSJZPq0QCCbJwJ4rRctBcBWZF3BgS3AGpOUM9S+ecSQDacQHYJkujg==",
       "requires": {
         "@peculiar/webcrypto": "^1.0.19",
         "emailjs": "^2.2.0",

+ 1 - 1
package.json

@@ -16,7 +16,7 @@
   "author": "Nikolay Suslov",
   "license": "MIT",
   "dependencies": {
-    "gun": "0.2019.915",
+    "gun": "0.2019.930",
     "optimist": "0.6.1"
   }
 }