From c86f38286e3164c8c5e4b2aee12c59a96123c021 Mon Sep 17 00:00:00 2001 From: wulin Date: Tue, 24 Oct 2023 16:43:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=8E=AF=E5=A2=83=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=89=93=E5=8D=B0=E6=97=A5=E5=BF=97id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/box/websocket/api/handler/BoxWebSocketHandler.java | 4 +--- .../box/websocket/api/handler/CustomerWebSocketHandler.java | 4 ++-- .../iot/box/websocket/api/service/BaseWebSocketService.java | 4 ++-- .../iot-box-websocket-api/src/main/resources/logback-test.xml | 2 +- .../iot-customer-http-api/src/main/resources/logback-test.xml | 2 +- 5 files changed, 7 insertions(+), 9 deletions(-) diff --git a/iot-modules/iot-box-websocket-api/src/main/java/com/qiuguo/iot/box/websocket/api/handler/BoxWebSocketHandler.java b/iot-modules/iot-box-websocket-api/src/main/java/com/qiuguo/iot/box/websocket/api/handler/BoxWebSocketHandler.java index 5ab7add..09dc2dd 100644 --- a/iot-modules/iot-box-websocket-api/src/main/java/com/qiuguo/iot/box/websocket/api/handler/BoxWebSocketHandler.java +++ b/iot-modules/iot-box-websocket-api/src/main/java/com/qiuguo/iot/box/websocket/api/handler/BoxWebSocketHandler.java @@ -234,10 +234,8 @@ public class BoxWebSocketHandler implements WebSocketHandler { }).flatMap(d -> { DeviceInfoEntity dv = (DeviceInfoEntity)d; boxSession.setDeviceId(dv.getId()); - + BoxSession oldBoxSession = baseWebSocketService.putBoxSession(sn, boxSession); return bindBox(boxSession, dv, userId, isBind).flatMap(db ->{ - BoxSession oldBoxSession = baseWebSocketService.getBoxSessionWithSn(sn); - baseWebSocketService.putBoxSession(sn, boxSession); if(oldBoxSession != null){ return baseWebSocketService.closeSendMsg(oldBoxSession, "您在其他地方登录", AskTypeEnum.TTS.getCode()); } diff --git a/iot-modules/iot-box-websocket-api/src/main/java/com/qiuguo/iot/box/websocket/api/handler/CustomerWebSocketHandler.java b/iot-modules/iot-box-websocket-api/src/main/java/com/qiuguo/iot/box/websocket/api/handler/CustomerWebSocketHandler.java index b285db9..bece4f7 100644 --- a/iot-modules/iot-box-websocket-api/src/main/java/com/qiuguo/iot/box/websocket/api/handler/CustomerWebSocketHandler.java +++ b/iot-modules/iot-box-websocket-api/src/main/java/com/qiuguo/iot/box/websocket/api/handler/CustomerWebSocketHandler.java @@ -170,8 +170,8 @@ public class CustomerWebSocketHandler implements WebSocketHandler { }else{ baseWebSocketService.normalSendMsg(userSession, "您暂未绑定果宝儿Box,快去绑定吧", AskTypeEnum.TTS.getCode()); } - UserSession oldUserSession = baseWebSocketService.getUserSessionWithUserId(userId); - baseWebSocketService.putUserSession(userId, userSession); + UserSession oldUserSession = baseWebSocketService.putUserSession(userId, userSession); + if(oldUserSession != null){ return baseWebSocketService.closeSendMsg(oldUserSession, "您在其他地方登录", AskTypeEnum.TTS.getCode()); } diff --git a/iot-modules/iot-box-websocket-api/src/main/java/com/qiuguo/iot/box/websocket/api/service/BaseWebSocketService.java b/iot-modules/iot-box-websocket-api/src/main/java/com/qiuguo/iot/box/websocket/api/service/BaseWebSocketService.java index 6caaea2..80bb995 100644 --- a/iot-modules/iot-box-websocket-api/src/main/java/com/qiuguo/iot/box/websocket/api/service/BaseWebSocketService.java +++ b/iot-modules/iot-box-websocket-api/src/main/java/com/qiuguo/iot/box/websocket/api/service/BaseWebSocketService.java @@ -238,16 +238,16 @@ public class BaseWebSocketService { int length, Long requestId){ if(n < length && baseSession.getRequestId().equals(requestId)){ + int start = n; n += ONE_MAX_TEXT; if(n > length){ n = length; } - String message = text.substring(n - ONE_MAX_TEXT, n); + String message = text.substring(start, n); int status = 0; if(n == length){ message += "。"; status = 1; - builder.setLength(0); } message = getSendStr(builder, message); int m = n; diff --git a/iot-modules/iot-box-websocket-api/src/main/resources/logback-test.xml b/iot-modules/iot-box-websocket-api/src/main/resources/logback-test.xml index 2328326..b2d3ad4 100644 --- a/iot-modules/iot-box-websocket-api/src/main/resources/logback-test.xml +++ b/iot-modules/iot-box-websocket-api/src/main/resources/logback-test.xml @@ -3,7 +3,7 @@ - + diff --git a/iot-modules/iot-customer-http-api/src/main/resources/logback-test.xml b/iot-modules/iot-customer-http-api/src/main/resources/logback-test.xml index dcd924f..3111e04 100644 --- a/iot-modules/iot-customer-http-api/src/main/resources/logback-test.xml +++ b/iot-modules/iot-customer-http-api/src/main/resources/logback-test.xml @@ -3,7 +3,7 @@ - +