1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Reset some changes to sample to be in line with how most of our nodes

actually are.
This commit is contained in:
dceejay 2015-01-12 19:11:07 +00:00
parent 2066d53d3f
commit fcec704b7b

View File

@ -31,6 +31,8 @@ module.exports = function(RED) {
// Store local copies of the node configuration (as defined in the .html) // Store local copies of the node configuration (as defined in the .html)
this.topic = n.topic; this.topic = n.topic;
// copy "this" object in case we need it in context of callbacks of other functions.
var node = this; var node = this;
// Do whatever you need to do in here - declare callbacks etc // Do whatever you need to do in here - declare callbacks etc
@ -43,16 +45,16 @@ module.exports = function(RED) {
// send out the message to the rest of the workspace. // send out the message to the rest of the workspace.
// ... this message will get sent at startup so you may not see it in a debug node. // ... this message will get sent at startup so you may not see it in a debug node.
node.send(msg); this.send(msg);
// respond to inputs.... // respond to inputs....
node.on('input', function (msg) { this.on('input', function (msg) {
node.warn("I saw a payload: "+msg.payload); node.warn("I saw a payload: "+msg.payload);
// in this example just send it straight on... should process it here really // in this example just send it straight on... should process it here really
node.send(msg); node.send(msg);
}); });
node.on("close", function() { this.on("close", function() {
// Called when the node is shutdown - eg on redeploy. // Called when the node is shutdown - eg on redeploy.
// Allows ports to be closed, connections dropped etc. // Allows ports to be closed, connections dropped etc.
// eg: node.client.disconnect(); // eg: node.client.disconnect();