From 62fba7e356ac710492d04052b789a6bd432fbf0f Mon Sep 17 00:00:00 2001 From: wulin Date: Sat, 21 Oct 2023 10:08:24 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3nacos=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=EF=BC=8C=E5=8F=91=E9=80=81=E5=AE=A2=E6=88=B7=E7=AB=AF=E5=BD=93?= =?UTF-8?q?=E5=8F=AA=E6=9C=89=E7=A9=BA=E6=A0=BC=E6=98=AF=E4=B8=8D=E6=8E=A8?= =?UTF-8?q?=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- iot-modules/iot-box-websocket-api/pom.xml | 6 +++++ .../api/handler/BaseWebSocketProcess.java | 22 +++++++++++++------ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/iot-modules/iot-box-websocket-api/pom.xml b/iot-modules/iot-box-websocket-api/pom.xml index 1fb4d40..757db4a 100644 --- a/iot-modules/iot-box-websocket-api/pom.xml +++ b/iot-modules/iot-box-websocket-api/pom.xml @@ -75,6 +75,12 @@ compile + + + com.github.ben-manes.caffeine + caffeine + 3.1.8 + diff --git a/iot-modules/iot-box-websocket-api/src/main/java/com/qiuguo/iot/box/websocket/api/handler/BaseWebSocketProcess.java b/iot-modules/iot-box-websocket-api/src/main/java/com/qiuguo/iot/box/websocket/api/handler/BaseWebSocketProcess.java index d58b1f8..63e1452 100644 --- a/iot-modules/iot-box-websocket-api/src/main/java/com/qiuguo/iot/box/websocket/api/handler/BaseWebSocketProcess.java +++ b/iot-modules/iot-box-websocket-api/src/main/java/com/qiuguo/iot/box/websocket/api/handler/BaseWebSocketProcess.java @@ -134,14 +134,18 @@ public class BaseWebSocketProcess { int m = Math.max(Math.max(Math.max(Math.max(d, j), Math.max(a, b)), c), n); if (m > 0) { //清空 - sb.setLength(0); - sb.append(old.substring(m)); - old = old.substring(0, m); + String msg = old.substring(0, m); + if(msg.replace(" ", "").length() > 0){ + //纯空格的不推送 + sb.setLength(0); + sb.append(old.substring(m)); + + normalSendMsg(baseSession, msg, type, YesNo.NO.getCode()); + return; + } - normalSendMsg(baseSession, old, type, YesNo.NO.getCode()); - } else { - sb.append(message); } + sb.append(message); return; } @@ -152,7 +156,11 @@ public class BaseWebSocketProcess { @Override public void finish() { log.info("千问最后调用finish"); - normalSendMsg(baseSession, sb.toString(), type); + String msg = sb.toString(); + if(msg.replace(" ", "").length() > 0){ + //纯空格的不推送 + normalSendMsg(baseSession, sb.toString(), type); + } MDC.remove(Log4Constans.PRINT_LOG_ID); } }).flatMap(data ->{