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 ->{