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:
parent
6edac99bd3
commit
aff51c116a
@ -1,7 +1,8 @@
|
||||
### 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.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.18 - Stop map contextmenu bleedthrough to marker. Add compress middleware.
|
||||
- v2.0.17 - Let clear command also clear tracks from tracks node
|
||||
|
@ -1,7 +1,5 @@
|
||||
# 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
|
||||
map web page for plotting "things" on.
|
||||
|
||||
@ -9,8 +7,9 @@ map web page for plotting "things" on.
|
||||
|
||||
### Updates
|
||||
|
||||
- v2.1.0 - Add ui-worldmap node to make embedding in Dashboard easier.
|
||||
- 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.18 - Stop map contextmenu bleedthrough to marker. Add compress middleware.
|
||||
- v2.0.17 - Let clear command also clear tracks from tracks node
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"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.",
|
||||
"dependencies": {
|
||||
"cgi": "0.3.1",
|
||||
|
@ -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>
|
||||
<input type="text" id="node-input-path" placeholder="worldmap">
|
||||
</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">
|
||||
<label for="node-input-name"><i class="fa fa-file"></i> Name</label>
|
||||
<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",
|
||||
defaults: {
|
||||
name: {value:""},
|
||||
path: {value:"/worldmap"}
|
||||
path: {value:"/worldmap"},
|
||||
events: {value:"all"}
|
||||
},
|
||||
inputs:0,
|
||||
outputs:1,
|
||||
|
13
worldmap.js
13
worldmap.js
@ -202,6 +202,7 @@ module.exports = function(RED) {
|
||||
var WorldMapIn = function(n) {
|
||||
RED.nodes.createNode(this,n);
|
||||
this.path = n.path || "/worldmap";
|
||||
this.events = n.events || "all";
|
||||
if (this.path.charAt(0) != "/") { this.path = "/" + this.path; }
|
||||
if (!sockets[this.path]) {
|
||||
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});
|
||||
client.on('data', function(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() {
|
||||
delete clients[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});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user