let worldap in node only send connect events if required.

(makes life easier for resends etc..)
Bump package etc in anticipation of release etc.
This commit is contained in:
Dave Conway-Jones 2019-09-02 15:08:34 +01:00
parent 6edac99bd3
commit aff51c116a
No known key found for this signature in database
GPG Key ID: 9E7F9C73F5168CD4
5 changed files with 25 additions and 8 deletions

View File

@ -1,7 +1,8 @@
### Change Log for Node-RED Worldmap ### 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.0.22 - fix SIDC missing property - v2.0.22 - fix SIDC missing property
- v2.0.21 - allow adding overlays without making them visible (visible:false) - Issue #108 - 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. - v2.0.20 - ensure `fit` option is boolean, Issue #109. Fix track layers, Issue #110.
- v2.0.18 - Stop map contextmenu bleedthrough to marker. Add compress middleware. - v2.0.18 - Stop map contextmenu bleedthrough to marker. Add compress middleware.
- v2.0.17 - Let clear command also clear tracks from tracks node - v2.0.17 - Let clear command also clear tracks from tracks node

View File

@ -1,7 +1,5 @@
# node-red-contrib-web-worldmap # node-red-contrib-web-worldmap
![NPM version](https://badge.fury.io/js/node-red-contrib-web-worldmap.svg)
A <a href="https://nodered.org" target="mapinfo">Node-RED</a> node to provide a world A <a href="https://nodered.org" target="mapinfo">Node-RED</a> node to provide a world
map web page for plotting "things" on. map web page for plotting "things" on.
@ -9,8 +7,9 @@ map web page for plotting "things" on.
### Updates ### Updates
- v2.1.0 - Add ui-worldmap node to make embedding in Dashboard easier.
- v2.0.22 - fix SIDC missing property - v2.0.22 - fix SIDC missing property
- v2.0.21 - allow adding overlays without making them visible (visible:false) - Issue #108 - 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. - v2.0.20 - ensure `fit` option is boolean, Issue #109. Fix track layers, Issue #110.
- v2.0.18 - Stop map contextmenu bleedthrough to marker. Add compress middleware. - v2.0.18 - Stop map contextmenu bleedthrough to marker. Add compress middleware.
- v2.0.17 - Let clear command also clear tracks from tracks node - v2.0.17 - Let clear command also clear tracks from tracks node

View File

@ -1,6 +1,6 @@
{ {
"name": "node-red-contrib-web-worldmap", "name": "node-red-contrib-web-worldmap",
"version": "2.0.22", "version": "2.1.0",
"description": "A Node-RED node to provide a web page of a world map for plotting things on.", "description": "A Node-RED node to provide a web page of a world map for plotting things on.",
"dependencies": { "dependencies": {
"cgi": "0.3.1", "cgi": "0.3.1",

View File

@ -437,6 +437,13 @@ then by default <code>⌘⇧m</code> - <code>ctrl-shift-m</code> will load the m
<label for="node-input-path"><i class="fa fa-globe"></i> Web Path</label> <label for="node-input-path"><i class="fa fa-globe"></i> Web Path</label>
<input type="text" id="node-input-path" placeholder="worldmap"> <input type="text" id="node-input-path" placeholder="worldmap">
</div> </div>
<div class="form-row">
<label for="node-input-events"><i class="fa fa-sign-out"></i> Output</label>
<select id="node-input-events" style="width:70%;">
<option value="all">All action events</option>
<option value="">Connect event only</option>
</select>
</div>
<div class="form-row"> <div class="form-row">
<label for="node-input-name"><i class="fa fa-file"></i> Name</label> <label for="node-input-name"><i class="fa fa-file"></i> Name</label>
<input type="text" id="node-input-name" placeholder="name"> <input type="text" id="node-input-name" placeholder="name">
@ -472,7 +479,8 @@ then by default <code>⌘⇧m</code> - <code>ctrl-shift-m</code> will load the m
color:"darksalmon", color:"darksalmon",
defaults: { defaults: {
name: {value:""}, name: {value:""},
path: {value:"/worldmap"} path: {value:"/worldmap"},
events: {value:"all"}
}, },
inputs:0, inputs:0,
outputs:1, outputs:1,

View File

@ -202,6 +202,7 @@ module.exports = function(RED) {
var WorldMapIn = function(n) { var WorldMapIn = function(n) {
RED.nodes.createNode(this,n); RED.nodes.createNode(this,n);
this.path = n.path || "/worldmap"; this.path = n.path || "/worldmap";
this.events = n.events || "all";
if (this.path.charAt(0) != "/") { this.path = "/" + this.path; } if (this.path.charAt(0) != "/") { this.path = "/" + this.path; }
if (!sockets[this.path]) { if (!sockets[this.path]) {
var libPath = path.posix.join(RED.settings.httpNodeRoot, this.path, 'leaflet', 'sockjs.min.js'); var libPath = path.posix.join(RED.settings.httpNodeRoot, this.path, 'leaflet', 'sockjs.min.js');
@ -218,12 +219,20 @@ module.exports = function(RED) {
node.status({fill:"green",shape:"dot",text:"connected "+Object.keys(clients).length,_sessionid:client.id}); node.status({fill:"green",shape:"dot",text:"connected "+Object.keys(clients).length,_sessionid:client.id});
client.on('data', function(message) { client.on('data', function(message) {
message = JSON.parse(message); message = JSON.parse(message);
setImmediate(function() {node.send({payload:message, topic:node.path.substr(1), _sessionid:client.id})}); 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 {
setImmediate(function() {node.send({payload:message, topic:node.path.substr(1), _sessionid:client.id})});
}
}); });
client.on('close', function() { client.on('close', function() {
delete clients[client.id]; delete clients[client.id];
node.status({fill:"green",shape:"ring",text:"connected "+Object.keys(clients).length,_sessionid:client.id}); node.status({fill:"green",shape:"ring",text:"connected "+Object.keys(clients).length,_sessionid:client.id});
node.send({payload:{action:"disconnect", clients:Object.keys(clients).length}, topic:node.path.substr(1), _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});
}
}); });
} }