12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- // var fs = require('fs'),
- // argv = require('optimist').argv
- var config = require('./readConfig');
- var Gun = require('gun')
- require('gun/sea')
- require('gun/lib/path')
- require('gun/lib/not')
- require('gun/nts')
- require('gun/lib/bye')
- config.readConfigFile();
- var conf = config.parseConfigOptions();
- var config = { port: conf.port };
- //create the server
- if (conf.ssl) {
- config.server = require('https').createServer(conf.sslOptions, Gun.serve(__dirname));
- } else {
- 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');
- let tickMsg = {
- parameters: "[]",
- time: 'tick',//hb
- sender: 'server'
- };
- global.gun.get('server').get('heartbeat').get('tick').put(tickMsg);
- //instance.get('heartbeat').put({ tick: "{}" }).heartbeat(0.0, 1);
- setInterval(function () {
- let message = {
- parameters: "[]",
- time: 'tick', //hb
- sender: 'server'
- };
- global.gun.get('server').get('heartbeat').get('tick').put(message,function(ack){
- if(ack.err){
- console.log('ERROR: ' + ack.err)
- }});
- }, 50);
|