From 527007f74b98d31d829bea8e1aec7afff26b49f0 Mon Sep 17 00:00:00 2001 From: zhangdaihao Date: Wed, 28 Aug 2019 20:03:49 +0800 Subject: [PATCH] =?UTF-8?q?websocket=E4=BC=9A=E8=87=AA=E5=8A=A8=E6=96=AD?= =?UTF-8?q?=E5=BC=80=EF=BC=8C=E6=96=AD=E5=BC=80=E6=97=B6=EF=BC=8C=E5=8F=91?= =?UTF-8?q?=E9=80=81=E9=80=9A=E7=9F=A5=E5=85=AC=E5=91=8A=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E6=8E=A8=E9=80=81=20#457?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/jeecg/modules/message/websocket/WebSocket.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/message/websocket/WebSocket.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/message/websocket/WebSocket.java index 5d8cc9cf..497b1193 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/message/websocket/WebSocket.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/message/websocket/WebSocket.java @@ -13,6 +13,8 @@ import javax.websocket.server.ServerEndpoint; import org.springframework.stereotype.Component; +import com.alibaba.fastjson.JSONObject; + import lombok.extern.slf4j.Slf4j; @Component @@ -48,7 +50,11 @@ public class WebSocket { @OnMessage public void onMessage(String message) { - log.info("【websocket消息】收到客户端消息:"+message); + //log.info("【websocket消息】收到客户端消息:"+message); + JSONObject obj = new JSONObject(); + obj.put("cmd", "heartcheck");//业务类型 + obj.put("msgTxt", "心跳响应");//消息内容 + session.getAsyncRemote().sendText(obj.toJSONString()); } // 此为广播消息 -- GitLab