From 3bbb9004cf7a70379ef45218393cd47fc1bc4010 Mon Sep 17 00:00:00 2001 From: huangwenlong Date: Wed, 14 Dec 2022 21:30:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B3=A8=E8=A7=A3=EF=BC=8CjavaScript=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=E5=88=86=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cc/iotkit/comp/tcp/parser/DirectPayloadParser.java | 2 +- .../cc/iotkit/comp/tcp/server/TcpServerVerticle.java | 8 +++++++- .../src/main/resources/scriptParser.js | 10 ++++++---- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/iot-components/iot-component-tcp/src/main/java/cc/iotkit/comp/tcp/parser/DirectPayloadParser.java b/iot-components/iot-component-tcp/src/main/java/cc/iotkit/comp/tcp/parser/DirectPayloadParser.java index 49fadd88..0000bb56 100644 --- a/iot-components/iot-component-tcp/src/main/java/cc/iotkit/comp/tcp/parser/DirectPayloadParser.java +++ b/iot-components/iot-component-tcp/src/main/java/cc/iotkit/comp/tcp/parser/DirectPayloadParser.java @@ -7,7 +7,7 @@ import reactor.core.publisher.Flux; import java.util.function.Function; /** - * 固定长度 + * 不处理 * * @author huangwenl * @date 2022-10-13 diff --git a/iot-components/iot-component-tcp/src/main/java/cc/iotkit/comp/tcp/server/TcpServerVerticle.java b/iot-components/iot-component-tcp/src/main/java/cc/iotkit/comp/tcp/server/TcpServerVerticle.java index e5d166e0..12121a8b 100644 --- a/iot-components/iot-component-tcp/src/main/java/cc/iotkit/comp/tcp/server/TcpServerVerticle.java +++ b/iot-components/iot-component-tcp/src/main/java/cc/iotkit/comp/tcp/server/TcpServerVerticle.java @@ -83,6 +83,9 @@ public class TcpServerVerticle extends AbstractVerticle { } + /** + * 初始TCP服务 + */ private void initTcpServer() { int instance = Math.max(2, config.getInstance()); List instances = new ArrayList<>(instance); @@ -127,6 +130,9 @@ public class TcpServerVerticle extends AbstractVerticle { } } + /** + * 保活定时任务 + */ public void keepClientTask() { scheduledThreadPoolExecutor = new ScheduledThreadPoolExecutor(2); @@ -236,7 +242,7 @@ public class TcpServerVerticle extends AbstractVerticle { } /** - * 递归断开连接 + * 断开连接,并移除子设备 */ private void clientDisconnect(String deviceName) { VertxTcpClient remove = clientMap.remove(deviceName); diff --git a/iot-components/iot-component-tcp/src/main/resources/scriptParser.js b/iot-components/iot-component-tcp/src/main/resources/scriptParser.js index b4f0e79a..b40625ef 100644 --- a/iot-components/iot-component-tcp/src/main/resources/scriptParser.js +++ b/iot-components/iot-component-tcp/src/main/resources/scriptParser.js @@ -1,4 +1,6 @@ -parser.delimited("\r\n") - .handler(function(buffer){ - parser.result(parser.newBuffer().toString("UTF-8")).complete(); - }); \ No newline at end of file +this.payloadParser = function (parser) { + parser.delimited("\r\n") + .handler(function(buffer){ + parser.result(buffer.toString("UTF-8")).complete(); + }); +} \ No newline at end of file