0.1.1 • Published 5 years ago
node-red-contrib-warp v0.1.1
node-red-contrib-warp
A node for Node-RED that can warps message directly to the specified nodes.
Installation
Use the Node-RED Manage palette option, or run the following command in your Node-RED directory (typically: ~/.node-red):
$ npm install node-red-contrib-warpUsage

Input messages
The msg.scope can be set as a comma-separated string, or an array of string.
If you choose selected nodes in the node configuration, the msg.scope property will not be used.



Examples
These flows demonstrates the operations of the warp node and the commands that can be used to change its state.
Basic Operation
Pass the message to the selected node in the following flow:

[{"id":"4a6dc584.248f5c","type":"inject","z":"f6f2187d.f17ca8","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":"","topic":"","payload":"123","payloadType":"num","x":290,"y":160,"wires":[["4cb0570.dc11ba8"]]},{"id":"4cb0570.dc11ba8","type":"warp","z":"f6f2187d.f17ca8","scope":["55d3323b.15db3c"],"destination":"selected","x":460,"y":160,"wires":[]},{"id":"55d3323b.15db3c","type":"debug","z":"f6f2187d.f17ca8","active":true,"tosidebar":true,"x":470,"y":220,"wires":[]},{"id":"4581fbf2.663664","type":"inject","z":"f6f2187d.f17ca8","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":"","topic":"","payload":"","payloadType":"date","x":300,"y":220,"wires":[["55d3323b.15db3c"]]}]Advanced Operation
Pass the message to the dynamically specified node in the following flow:

[{"id":"29571f4a.bd258","type":"function","z":"f6f2187d.f17ca8","name":"","func":"const args = msg.payload\n\nif ((args.username)\n && (typeof args.username == 'string')) {\n \n // ok\n return [msg, null]\n \n} else {\n // missing param\n msg.payload = {\n checkpoint: node.id,\n data: args,\n message: 'Missing mandatory parameter [username].'\n }\n return [null, msg]\n}","outputs":2,"noerr":0,"initialize":"","finalize":"","x":460,"y":180,"wires":[["b5785af6.8fc528"],["6ede4eb5.3b876"]],"outputLabels":["Ok","missing params"]},{"id":"e475e333.a75f8","type":"warp","z":"f6f2187d.f17ca8","name":"","scope":null,"destination":"varmsg","x":610,"y":380,"wires":[]},{"id":"a71c67d1.9612c8","type":"http in","z":"f6f2187d.f17ca8","name":"","url":"/register","method":"post","upload":false,"swaggerDoc":"","x":130,"y":180,"wires":[["f78b9a18.c581d8"]]},{"id":"d22d192c.ef3ef8","type":"http in","z":"f6f2187d.f17ca8","name":"","url":"/resume/:checkpoint","method":"post","upload":false,"swaggerDoc":"","x":170,"y":380,"wires":[["1974c92f.2ccd77"]]},{"id":"1974c92f.2ccd77","type":"change","z":"f6f2187d.f17ca8","name":"set msg.scope","rules":[{"t":"set","p":"scope","pt":"msg","to":"req.params.checkpoint","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":380,"wires":[["e475e333.a75f8"]]},{"id":"f78b9a18.c581d8","type":"function","z":"f6f2187d.f17ca8","name":"dummy","func":"// Intermediate processing...\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":300,"y":180,"wires":[["29571f4a.bd258"]]},{"id":"d39ca728.e45138","type":"http response","z":"f6f2187d.f17ca8","name":"ok","statusCode":"","headers":{},"x":750,"y":160,"wires":[]},{"id":"6ede4eb5.3b876","type":"http response","z":"f6f2187d.f17ca8","name":"missing params","statusCode":"","headers":{},"x":640,"y":200,"wires":[]},{"id":"b5785af6.8fc528","type":"template","z":"f6f2187d.f17ca8","name":"","field":"payload","fieldType":"msg","format":"json","syntax":"mustache","template":"{\n \"id\": 1,\n \"username\": \"{{payload.username}}\"\n}","output":"json","x":620,"y":160,"wires":[["d39ca728.e45138"]]}]License
This project is released under the MIT License.