From 8306ddd40f3ec34fd555634510bd46c01fddb770 Mon Sep 17 00:00:00 2001 From: Hiroyasu Nishiyama Date: Wed, 3 Feb 2021 17:01:29 +0900 Subject: [PATCH] add examples for TCP in/out node --- .../tcp/01 - Connect to TCP out server.json | 92 +++++++++ .../tcp/02 - Connect to TCP in server.json | 92 +++++++++ ...end reply to client of TCP connection.json | 174 ++++++++++++++++++ 3 files changed, 358 insertions(+) create mode 100644 packages/node_modules/@node-red/nodes/examples/network/tcp/01 - Connect to TCP out server.json create mode 100644 packages/node_modules/@node-red/nodes/examples/network/tcp/02 - Connect to TCP in server.json create mode 100644 packages/node_modules/@node-red/nodes/examples/network/tcp/03 - Send reply to client of TCP connection.json diff --git a/packages/node_modules/@node-red/nodes/examples/network/tcp/01 - Connect to TCP out server.json b/packages/node_modules/@node-red/nodes/examples/network/tcp/01 - Connect to TCP out server.json new file mode 100644 index 000000000..78c24760c --- /dev/null +++ b/packages/node_modules/@node-red/nodes/examples/network/tcp/01 - Connect to TCP out server.json @@ -0,0 +1,92 @@ +[ + { + "id": "73874b9e.d985b4", + "type": "tcp in", + "z": "cfd9159c.6f73e8", + "name": "", + "server": "client", + "host": "localhost", + "port": "1881", + "datamode": "single", + "datatype": "utf8", + "newline": "", + "topic": "", + "base64": false, + "x": 230, + "y": 240, + "wires": [ + [ + "ce332113.d2c31" + ] + ] + }, + { + "id": "a4bd9948.dfeb58", + "type": "tcp out", + "z": "cfd9159c.6f73e8", + "host": "localhost", + "port": "1881", + "beserver": "server", + "base64": false, + "end": true, + "name": "", + "x": 390, + "y": 180, + "wires": [] + }, + { + "id": "9f80f9c7.1e3c98", + "type": "inject", + "z": "cfd9159c.6f73e8", + "name": "", + "props": [ + { + "p": "payload" + }, + { + "p": "topic", + "vt": "str" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", + "payload": "Hello, World!", + "payloadType": "str", + "x": 210, + "y": 180, + "wires": [ + [ + "a4bd9948.dfeb58" + ] + ] + }, + { + "id": "ce332113.d2c31", + "type": "debug", + "z": "cfd9159c.6f73e8", + "name": "", + "active": true, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "false", + "statusVal": "", + "statusType": "auto", + "x": 410, + "y": 240, + "wires": [] + }, + { + "id": "711ed10d.1d765", + "type": "comment", + "z": "cfd9159c.6f73e8", + "name": "Connect to TCP out server", + "info": "`TCP in` node can connect to network server using tcp protocol. `TCP out` node can serve a network server using tcp procol.\n", + "x": 190, + "y": 120, + "wires": [] + } +] \ No newline at end of file diff --git a/packages/node_modules/@node-red/nodes/examples/network/tcp/02 - Connect to TCP in server.json b/packages/node_modules/@node-red/nodes/examples/network/tcp/02 - Connect to TCP in server.json new file mode 100644 index 000000000..357cbb9ca --- /dev/null +++ b/packages/node_modules/@node-red/nodes/examples/network/tcp/02 - Connect to TCP in server.json @@ -0,0 +1,92 @@ +[ + { + "id": "511f8208.c4c20c", + "type": "tcp in", + "z": "cfd9159c.6f73e8", + "name": "", + "server": "server", + "host": "localhost", + "port": "1882", + "datamode": "single", + "datatype": "utf8", + "newline": "", + "topic": "", + "base64": false, + "x": 230, + "y": 460, + "wires": [ + [ + "6b8be121.32be9" + ] + ] + }, + { + "id": "ec0bc4aa.b3c828", + "type": "tcp out", + "z": "cfd9159c.6f73e8", + "host": "localhost", + "port": "1882", + "beserver": "client", + "base64": false, + "end": true, + "name": "", + "x": 390, + "y": 400, + "wires": [] + }, + { + "id": "17cf7d56.9efb03", + "type": "inject", + "z": "cfd9159c.6f73e8", + "name": "", + "props": [ + { + "p": "payload" + }, + { + "p": "topic", + "vt": "str" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", + "payload": "Hello, World!", + "payloadType": "str", + "x": 210, + "y": 400, + "wires": [ + [ + "ec0bc4aa.b3c828" + ] + ] + }, + { + "id": "6b8be121.32be9", + "type": "debug", + "z": "cfd9159c.6f73e8", + "name": "", + "active": true, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "false", + "statusVal": "", + "statusType": "auto", + "x": 410, + "y": 460, + "wires": [] + }, + { + "id": "76196665.7c23e8", + "type": "comment", + "z": "cfd9159c.6f73e8", + "name": "Connect to TCP in server", + "info": "`TCP out` node can connect to network server using tcp protocol. `TCP in` node can serve a network server using tcp procol.\n", + "x": 190, + "y": 340, + "wires": [] + } +] \ No newline at end of file diff --git a/packages/node_modules/@node-red/nodes/examples/network/tcp/03 - Send reply to client of TCP connection.json b/packages/node_modules/@node-red/nodes/examples/network/tcp/03 - Send reply to client of TCP connection.json new file mode 100644 index 000000000..b4a324261 --- /dev/null +++ b/packages/node_modules/@node-red/nodes/examples/network/tcp/03 - Send reply to client of TCP connection.json @@ -0,0 +1,174 @@ +[ + { + "id": "d9a91d7e.05f0d", + "type": "tcp in", + "z": "cfd9159c.6f73e8", + "name": "", + "server": "server", + "host": "localhost", + "port": "1883", + "datamode": "stream", + "datatype": "utf8", + "newline": "¥n", + "topic": "", + "base64": false, + "x": 230, + "y": 740, + "wires": [ + [ + "3871d8af.25e208" + ] + ] + }, + { + "id": "9fa8f09d.7591b", + "type": "inject", + "z": "cfd9159c.6f73e8", + "name": "", + "props": [ + { + "p": "payload" + }, + { + "p": "topic", + "vt": "str" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", + "payload": "\"Hello, World!¥n\"", + "payloadType": "jsonata", + "x": 190, + "y": 640, + "wires": [ + [ + "948a8410.ab0a08" + ] + ] + }, + { + "id": "33df08b.753e9f8", + "type": "debug", + "z": "cfd9159c.6f73e8", + "name": "", + "active": true, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "false", + "statusVal": "", + "statusType": "auto", + "x": 710, + "y": 640, + "wires": [] + }, + { + "id": "948a8410.ab0a08", + "type": "tcp request", + "z": "cfd9159c.6f73e8", + "server": "localhost", + "port": "1883", + "out": "char", + "splitc": "\\n", + "name": "", + "x": 350, + "y": 640, + "wires": [ + [ + "f6d6be6a.efb4c" + ] + ] + }, + { + "id": "fbd442d8.cb273", + "type": "tcp out", + "z": "cfd9159c.6f73e8", + "host": "", + "port": "", + "beserver": "reply", + "base64": false, + "end": false, + "name": "", + "x": 530, + "y": 740, + "wires": [] + }, + { + "id": "3871d8af.25e208", + "type": "change", + "z": "cfd9159c.6f73e8", + "name": "set result", + "rules": [ + { + "t": "set", + "p": "payload", + "pt": "msg", + "to": "\"Received: \" & payload & \"\b\\n\"", + "tot": "jsonata" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 400, + "y": 740, + "wires": [ + [ + "fbd442d8.cb273" + ] + ] + }, + { + "id": "f6d6be6a.efb4c", + "type": "function", + "z": "cfd9159c.6f73e8", + "name": "Buffer to String", + "func": "msg.payload = msg.payload.toString();\nreturn msg;", + "outputs": 1, + "noerr": 0, + "initialize": "", + "finalize": "", + "x": 540, + "y": 640, + "wires": [ + [ + "33df08b.753e9f8" + ] + ] + }, + { + "id": "e1412987.91dcc8", + "type": "comment", + "z": "cfd9159c.6f73e8", + "name": "Send reply to client of TCP connection", + "info": "Input message from `TCP in` node may be passed to `TCP out` node to return a reply to client.\n", + "x": 230, + "y": 580, + "wires": [] + }, + { + "id": "5f43905f.2425d", + "type": "comment", + "z": "cfd9159c.6f73e8", + "name": "↓ Accept request", + "info": "", + "x": 220, + "y": 700, + "wires": [] + }, + { + "id": "a6f57329.c87c6", + "type": "comment", + "z": "cfd9159c.6f73e8", + "name": "↓ Reply result", + "info": "", + "x": 550, + "y": 700, + "wires": [] + } +] \ No newline at end of file