I'm trying to understand the difference between using node.send()
and send()
in a node. This is for the Node-RED MCU Edition exploration, to be able to properly enumerate the full Node-RED behavior. when using the CompatibilityNodeto run nodes.
The "JavaScript file" document Sending Messages section says:
If the node wants to send from inside the
input
event listener, in response to receiving a message, it should use thesend
function that is passed to the listener function:
On the page "Creating your first node", the example calls node.send()
instead of send()
from within the input
event listener.
node.on('input', function(msg) {
msg.payload = msg.payload.toLowerCase();
node.send(msg);
});
This seems to contradict the "JavaScript file" document which suggests writing it this way:
node.on('input', function(msg, send) {
msg.payload = msg.payload.toLowerCase();
send(msg);
});
Finally, the "Writing Functions" page under "Sending messages asynchronously" uses node.send()
and it appears this is the only option as there is no send
available to "On Message"
.
Apart from the note in "Sending Messages" in the "JavaScript file" document, it appears acceptable to use node.send()
everywhere. What is different about using send()
?