fix -in node connect event logic from being backwards

and remove extraneous debug
This commit is contained in:
Dave Conway-Jones 2019-09-02 15:19:09 +01:00
parent aff51c116a
commit f8a4f4207e
No known key found for this signature in database
GPG Key ID: 9E7F9C73F5168CD4
3 changed files with 8 additions and 7 deletions

View File

@ -1,6 +1,6 @@
### Change Log for Node-RED Worldmap
- v2.1.0 - Add ui-worldmap node to make embedding in Dashboard easier. Let in node specify connection actions only.
- v2.1.0 - Add ui-worldmap node to make embedding in Dashboard easier. Let -in node specify connection actions only.
- v2.0.22 - fix SIDC missing property
- v2.0.21 - allow adding overlays without making them visible (visible:false). Issue #108
- v2.0.20 - ensure `fit` option is boolean, Issue #109. Fix track layers, Issue #110.

View File

@ -7,7 +7,7 @@ map web page for plotting "things" on.
### Updates
- v2.1.0 - Add ui-worldmap node to make embedding in Dashboard easier.
- v2.1.0 - Add ui-worldmap node to make embedding in Dashboard easier. Let -in node specify connection actions only.
- v2.0.22 - fix SIDC missing property
- v2.0.21 - allow adding overlays without making them visible (visible:false). Issue #108
- v2.0.20 - ensure `fit` option is boolean, Issue #109. Fix track layers, Issue #110.

View File

@ -219,17 +219,18 @@ module.exports = function(RED) {
node.status({fill:"green",shape:"dot",text:"connected "+Object.keys(clients).length,_sessionid:client.id});
client.on('data', function(message) {
message = JSON.parse(message);
console.log("GOT:",message);
if ((node.events === "connect") && message.hasOwnProperty("action") && (message.action === "connected")) {
setImmediate(function() {node.send({payload:message, topic:node.path.substr(1), _sessionid:client.id})});
} else {
if (node.events !== "connect") {
setImmediate(function() {node.send({payload:message, topic:node.path.substr(1), _sessionid:client.id})});
}
else {
if (message.hasOwnProperty("action") && (message.action === "connected")) {
setImmediate(function() {node.send({payload:message, topic:node.path.substr(1), _sessionid:client.id})});
}
}
});
client.on('close', function() {
delete clients[client.id];
node.status({fill:"green",shape:"ring",text:"connected "+Object.keys(clients).length,_sessionid:client.id});
console.log("BYE:",node.events);
if (node.events !== "connect") {
node.send({payload:{action:"disconnect", clients:Object.keys(clients).length}, topic:node.path.substr(1), _sessionid:client.id});
}