Add UDP out into function/custom node

I have created a custom node and would like to incorporate the link out node into it.
Is that possible?
It's that or somehow add the functions that are performed at the link in to the custom node.

My node.js

module.exports = function(RED) {
    function PhoneNumberNode(config) {
	this.number = config.number;
        var node = this;
        this.on('input', function(msg) {
            msg.number = node.number;

Example flow:

[{"id":"8aadf171.517b6","type":"link in","z":"64a5e2ea.298e7c","name":"SMS","links":["34ec2c86.ba6c64","251c2ea4.db6e32","fecdfa88.4b14e8"],"x":455,"y":1200,"wires":[["565a8587.79193c"]]},{"id":"565a8587.79193c","type":"function","z":"64a5e2ea.298e7c","name":"Prepare Message","func":"msg.message = Buffer.from(msg.payload,\"utf8\").toString(\"Hex\"),\nmsg.chr = msg.payload.length,\nmsg.payload = msg.number + \",ASCII,\"+ msg.chr + \",\" + msg.message\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":590,"y":1200,"wires":[["6d438163.fbf47"]]},{"id":"6d438163.fbf47","type":"udp out","z":"64a5e2ea.298e7c","name":"SMS Out","addr":"","iface":"","port":"1147","ipv":"udp4","outport":"1147","base64":false,"multicast":"false","x":760,"y":1200,"wires":[]},{"id":"fecdfa88.4b14e8","type":"link out","z":"64a5e2ea.298e7c","name":"Darren SMS","links":["87935307.973b5","a2b4e8ea.fbce58","8aadf171.517b6"],"x":355,"y":1200,"wires":[]},{"id":"4f854124.c9b1a","type":"phonenumber","z":"64a5e2ea.298e7c","name":"User Name","number":"18881234567","x":210,"y":1200,"wires":[["fecdfa88.4b14e8"]]}]


This is a really bad idea. It removes point of wiring nodes together so you can see where messages are going.

What problem are you trying to solve by doing this?

Ya I think i see that now.
So I included the Prepare Message function into my custom node, now i just need to include the SMS Out which is a UDP out.

Is there an easy way to call the UPD function using a custom node?
I have the message formatted so all I need to do now is send it out to IP on port 1147.

Again, what problem are you trying to solve by adding that feature to your node that can't be solved just by wiring it to a UDP node?

I use this node to send SMS messages to list of people.
There could be a hundred numbers and each custom node would then need an additional link out.

Why would it need a separate link out? I assume you are sending the UDP packets to the same IP and Port and since the phone number is in the message?

Because I'm a noob and don't know how to add the "Send UDP" function to my custom node. So for now I'm linking them individually.

I'm saying you only need one UDP node to handle all the output.

But if you really want to include it in your node, the source code for all the core nodes is on github so you are perfectly free to read it and learn from it.

I think i get what you're saying. I just would like to not have to "wire" all the custom nodes back to the upd out. I don't really know what Node-Red is capable but this is probably beyond my skills.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.