Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jdiscovery update #10

Open
wants to merge 64 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
913c12e
Removed local registry from jdiscovery
May 23, 2018
4467640
Moved jdisc tester, dup elim true by default
May 24, 2018
b7a41f6
JDISC: Enabled clean sessions in MQTT registry
May 25, 2018
6e192c3
JDISC: Removed default discovery of clouds by devs
May 25, 2018
1cade4f
JDISC: Readded default cloud discovery for devs
May 29, 2018
21bbf37
JDISC: MQTT: Added exit procedure + Implemented new policy
May 29, 2018
af8da2b
JDISC: Fixed status clearing in mqtt exit
May 29, 2018
b3f002f
JDISC: MQTT registry uses QoS 1 exclusively
May 31, 2018
8f2bcc8
JDISC: __PARTIAL__ Implementing FIFO event ordering && code refactoring
May 31, 2018
c804aa8
JDISC: __PARTIAL__ Seq num update
May 31, 2018
5692e5b
JDISC: jregistar: seqval update, interface change
Jun 4, 2018
72c5d7e
JDISC: var name changes...
Jun 4, 2018
b8f8ae6
JDISC: More var name changes...
Jun 4, 2018
01fea92
JDISC: Added dattrs format conversion in jregistar
Jun 4, 2018
4b69e3b
JDISC: jregistar: Fixed seqval use error, refactoring
Jun 4, 2018
2d72ad2
JDISC: Fixed format marshalling for dattrs
Jun 5, 2018
a225b92
JDISC: Refactoring MQTTreg, jreg and more...
Jun 5, 2018
e59ee80
JDISC: Update mqtt registry behaviour and impl (in progress)
Jun 5, 2018
59307d6
JDISC: MQTTreg overhaul completed
Jun 6, 2018
040d06b
JDISC: Fixing lambda expr brackets.. Oops
Jun 6, 2018
680867b
JDISC: Bug fixes, and seq # scheme update
Jun 7, 2018
faad81f
JDISC: Started mDNSreg overhaul
Jun 7, 2018
b4dd5ed
JDISC: Refactoring & implemented start lock in mqttreg
Jun 8, 2018
d203a2a
JDISC: mdnsreg refactoring
Jun 8, 2018
769f26b
JDISC: Modifiying mDNSreg (in progress), bug fix for jreg
Jun 8, 2018
335f58a
JDISC: mDNS registry structural update done, bug with advs..
Jun 11, 2018
c670837
Basic service discovery working! Trouble with dup elim
Jun 12, 2018
c524484
JDISC: Modifying mDNS attr update/removal policies (in prog)
Jun 14, 2018
9ba618c
JDISC: Finished mDNS policy change (not tested)
Jun 14, 2018
ea6ca83
JDISC: Fixed syntax for Object.keys()
Jun 15, 2018
ebe1d32
JDISC: MDNSRegistry: Added debug messages
Jun 18, 2018
0b9d7bc
JDISC: Removed attrChgCaching in MDNSReg, Updated tester
Jun 18, 2018
d97d057
JDISC: MDNSReg: Moved to pure js mdns impl, still single process bound
Jun 19, 2018
d7a07f3
JDISC: Fixed bugs in MDNSReg and JRegistrar, MQTTReg working well, is…
Jun 19, 2018
7dbe1e6
JDISC: MDNSReg: Fixed attrRemovalAd reception delay error
Jun 20, 2018
7314fcf
JDISC: MDNSReg: Made mdns attr removal scheme more robust
Jun 21, 2018
ef72441
JDISC: Moving discovery services to secondary process (in progress)
Jun 21, 2018
2ad0dcc
JDISC: Lib moved to another process (complete/working)
Jun 22, 2018
163406b
JDISC: Merge with branch master
Jun 26, 2018
318d234
JDISC: Updated dependencies for script install
Jun 26, 2018
c8c7762
JDISC: Fixed path for child spawning
Jun 26, 2018
83b0152
JDISC: JAM Integration and arg array marshalling in jreg
Jun 27, 2018
95b3b19
JDISC: Fixed array arg marshalling in jreg
Jun 27, 2018
ac31c7b
JDISC: Updated README (in progress)
Jun 27, 2018
b394eac
JDISC: Updating docs (in progress)
Jun 29, 2018
17d4678
JDISC: Updating docs...
Jun 29, 2018
d467980
JDISC: Updating docs...
Jun 29, 2018
806fe72
JDISC: Updating docs...
Jun 29, 2018
ad23441
JDISC: Updating docs...
Jun 29, 2018
58a36ac
JDISC: Updating docs...
Jun 29, 2018
afd9754
JDISC: Updated docs!
Jun 29, 2018
80a2a5d
JDISC: Removed reserved attr list
Jun 29, 2018
3887c97
JDISC: Added getDiscoveryTable(handler) for dt pull, tested
Jul 3, 2018
6d6c017
Updated aux repos & JDISC: README.md minor changes
Jul 4, 2018
6b39320
JDISC: Implemented mDNSreg heartbeat feature
Jul 4, 2018
1499145
JDISC: Updated docs, updated apps/demo.js
Jul 5, 2018
93f6520
JDISC: Fixed 'this' bind issue in apps/demo.js
Jul 5, 2018
00ffa2b
JDISC: Enabled mqtt in apps/demo.js, fixed docs
Jul 5, 2018
5794aa3
JDISC: Added child kill check, commented out debug loggers
Jul 5, 2018
e9d9bb3
JDISC: Fixed inconsistency in README.md
Jul 5, 2018
6e1b9d5
JDISC: Fixed mdns name already exists timing error, added easier valu…
Jul 6, 2018
08a3120
JDISC: Added multi-app support on single LAN
Jul 6, 2018
327398e
JDISC: Removed [options] arg from registerAndDiscover (redundant and …
Jul 6, 2018
dbb9c0a
Merge branch 'master' into jdiscovery-update
Jul 6, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions lib/jamserver/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,14 @@ module.exports = Object.freeze({
retryInterval: 2000, // 2 seconds
longRetryInterval: 60000, // 1 minute
localBrokerUrl: 'http://localhost:1883',
brokerUrl: 'tcp://jamscript.madhacker.biz:1883'
brokerUrl: 'http://localhost:1884'
},

mdns: {
retries: 5,
retryInterval: 2000, // 2 seconds
longRetryInterval: 60000 // 1 minute
retryInterval: 2000,
heartBeatPort: 5454,
heartBeatMulticastAddress: '239.0.0.251',
heartBeatTTL: 1000
},

localStorage: {
Expand Down
74 changes: 37 additions & 37 deletions lib/jamserver/jamlib.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

// Load the global modules
const mqtt = require('mqtt'),
os = require('os'),
os = require('os'),
globals = require('./constants').globals;

// Do command line processing...
Expand All @@ -26,11 +26,11 @@ var machType = getMachineType(cmdopts);
deviceParams.setItem('machType', machType);

var reggie = new Registrar(cmdopts.app, machType, deviceParams.getItem('deviceId'),
cmdopts.port, {long: cmdopts.long, lat: cmdopts.lat}, { protocols: { mqtt: false, mdns: true, localStorage: false } });
cmdopts.port, { protocols: { mqtt: true, mdns: true } });

var jamsys = require('./jamsys');
jamsys.init(reggie, machType, cmdopts.tags, cmdopts.iflow, cmdopts.oflow, deviceParams.getItem('deviceId'),
cmdopts.link, cmdopts.long, cmdopts.lat);
cmdopts.link, cmdopts.long, cmdopts.lat);
jamsys.setMQTT(getMachineAddr(), cmdopts.port);


Expand All @@ -39,60 +39,60 @@ jnode.init(reggie, machType);


module.exports = new function() {
this.registerFuncs = registerFuncs;
this.run = run;
this.registerFuncs = registerFuncs;
this.run = run;
}

function run(callback) {

// Check the presence of the MQTT server.
// If not, report an error and quit
// Check the presence of the MQTT server.
// If not, report an error and quit

checkMQTTServer(function(present) {
if (!present) {
console.log("ERROR! Cannot connect to MQTT server. Exiting.");
process.exit(1);
}
checkMQTTServer(function(present) {
if (!present) {
console.log("ERROR! Cannot connect to MQTT server. Exiting.");
process.exit(1);
}

if (machType === globals.NodeType.CLOUD) {
reggie.registerAndDiscover();
jnode.startService();
jnode.startRunner();
} else {
jnode.doRegister();
jnode.startService();
jnode.startRunner();
jnode.startService();
jnode.startRunner();
} else {
jnode.doRegister();
jnode.startService();
jnode.startRunner();

}
}

if (callback !== undefined)
callback();
});
if (callback !== undefined)
callback();
});

}

function registerFuncs(machbox) {

// Register all callbacks in the machbox.
// These are functions registered by the application
fkeys = Object.keys(machbox.functions);
for (i in fkeys) {
tkey = fkeys[i];
jnode.registerCallback(tkey, machbox.functions[tkey], machbox.signatures[tkey]);
}
// Register all callbacks in the machbox.
// These are functions registered by the application
fkeys = Object.keys(machbox.functions);
for (i in fkeys) {
tkey = fkeys[i];
jnode.registerCallback(tkey, machbox.functions[tkey], machbox.signatures[tkey]);
}
}

// Check whether the MQTT server is up and running..
function checkMQTTServer(callback) {
var tserv = mqtt.connect("mqtt://localhost:" + cmdopts.port );
tserv.on('connect', function() {
tserv.end();
callback(true);
});
tserv.on('offline', function() {
var tserv = mqtt.connect("mqtt://localhost:" + cmdopts.port );
tserv.on('connect', function() {
tserv.end();
callback(true);
});
tserv.on('offline', function() {
tserv.end();
callback(false);
});
callback(false);
});
}


Expand Down
2 changes: 1 addition & 1 deletion lib/jamserver/jamsys.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ module.exports = new function() {
this.setupAdvertisement(aname);
}

reggie.addAttributes(attr);
reggie.setAttributes(attr);
}

// Advertise aname off
Expand Down
Loading