mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Expand the non-functional sample to have an input to make it more useful
This commit is contained in:
parent
da61fe12d0
commit
a718f34c58
@ -65,7 +65,7 @@
|
|||||||
name: {value:""}, // along with default values.
|
name: {value:""}, // along with default values.
|
||||||
topic: {value:"", required:true}
|
topic: {value:"", required:true}
|
||||||
},
|
},
|
||||||
inputs:0, // set the number of inputs - only 0 or 1
|
inputs:1, // set the number of inputs - only 0 or 1
|
||||||
outputs:1, // set the number of outputs - 0 to n
|
outputs:1, // set the number of outputs - 0 to n
|
||||||
// set the icon (held in icons dir below where you save the node)
|
// set the icon (held in icons dir below where you save the node)
|
||||||
icon: "myicon.png", // saved in icons/myicon.png
|
icon: "myicon.png", // saved in icons/myicon.png
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
module.exports = function(RED) {
|
module.exports = function(RED) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
// require any external libraries we may need....
|
||||||
|
//var foo = require("foo-library");
|
||||||
|
|
||||||
// The main node definition - most things happen in here
|
// The main node definition - most things happen in here
|
||||||
function SampleNode(n) {
|
function SampleNode(n) {
|
||||||
@ -41,6 +43,13 @@ 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.send(msg);
|
this.send(msg);
|
||||||
|
|
||||||
|
// respond to inputs....
|
||||||
|
this.on('input', function (msg) {
|
||||||
|
node.warn("I saw a payload: "+msg.payload);
|
||||||
|
// in this example just send it straight on... should process it here really
|
||||||
|
this.send(msg);
|
||||||
|
}
|
||||||
|
|
||||||
this.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.
|
||||||
|
Loading…
Reference in New Issue
Block a user