diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java index 49607a3..3ddf2f7 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java @@ -73,11 +73,7 @@ public class InteractiveSchedule { CompletableFuture.runAsync(() -> { WebSocketSession session = InteractiveSessionManager.get(answerVO.getSessionId()); TextMessage message = InteractiveSessionManager.getTextMessage("1",JSON.toJSONString(answerVO)); - try { - session.sendMessage(message); - } catch (IOException e) { - XxlJobLogger.log("消息中心推送失败,推送内容为:" + JSON.toJSONString(answerVO)); - } + wsService.sendMessage(session,message); }, getAnswerPoolExecutor); }); return ReturnT.SUCCESS; diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/service/InteractiveWsService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/service/InteractiveWsService.java index c7cce27..258a376 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/service/InteractiveWsService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/service/InteractiveWsService.java @@ -19,13 +19,18 @@ import java.io.IOException; public class InteractiveWsService implements WebSocketService { @Override - public Boolean sendMessage(String signage, TextMessage message) { - WebSocketSession session = InteractiveSessionManager.get(signage); + public Boolean sendMessage(String sessionId, TextMessage message) { + WebSocketSession session = InteractiveSessionManager.get(sessionId); + return this.sendMessage(session,message); + } + + @Override + public Boolean sendMessage(WebSocketSession session, TextMessage message) { try { session.sendMessage(message); return true; } catch (IOException e) { - log.error("消息推送失败,推送sessionId为:" + signage + ";消息体为:" + JSON.toJSONString(message)); + log.error("消息推送失败;消息体为:" + JSON.toJSONString(message)); return false; } } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/service/WebSocketService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/service/WebSocketService.java index f4937ad..8729472 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/service/WebSocketService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/service/WebSocketService.java @@ -1,6 +1,7 @@ package com.hnac.hzims.bigmodel.websocket.service; import org.springframework.web.socket.TextMessage; +import org.springframework.web.socket.WebSocketSession; /** * @Author: huangxing @@ -10,4 +11,6 @@ public interface WebSocketService { Boolean sendMessage(String signage, TextMessage message); + Boolean sendMessage(WebSocketSession session, TextMessage message); + }