@rico24 and here is an updated node_helper, that rejects connecting clients if they don’t send the right kind of identifier (ends with a digit)
var NodeHelper = require('node_helper');
var request = require('request');
module.exports = NodeHelper.create({
initial_counter:10000,
start: function() {
this.countDown = {}
},
isDigit: function(x){
return (x>='0' && x< ='9') // watch out for spaces after < , forum hides it all
},
socketNotificationReceived: function(notification, payload) {
console.log("Payload: =" + JSON.stringify(payload));
switch(notification){
case "DO_YOUR_JOB":
if(this.isDigit(payload.identifier.slice(-1))){
if(!this.countDown.hasOwnProperty(payload.identifier+this.ourpage)){
this.countDown[payload.identifier]=this.initial_counter;
}
let return_payload={identifier: payload.identifier, value:(this.countDown[payload.identifier] - payload.value)}
this.sendSocketNotification("I_DID",return_payload )
console.log("Payload 2: = " + JSON.stringify(return_payload));
}
else
this.sendSocketNotification("I_DID_REJECTED_INVALID_IDENTIFIER",payload )
break
}
},
});