From 0f84522c9b6857dbfdf2380817a38c6717a80c45 Mon Sep 17 00:00:00 2001
From: rays <1615175118@qq.com>
Date: Thu, 3 Jun 2021 16:02:15 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9WebSocket=E5=AE=9E=E7=8E=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pom.xml | 7 ++
src/main/resources/application.yml | 9 +--
.../expand/module/webSocket/webSocket.js | 6 +-
src/main/webapp/pages/index.html | 70 ++++++++++++++-----
4 files changed, 69 insertions(+), 23 deletions(-)
diff --git a/pom.xml b/pom.xml
index ffd46ae3..c9312f8d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -135,6 +135,13 @@
${roses.kernel.version}
+
+
+ cn.stylefeng.roses
+ socket-spring-boot-starter
+ ${roses.kernel.version}
+
+
cn.stylefeng.roses
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index 31be9c68..360afec6 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -2,6 +2,11 @@ server:
port: 8080
max-http-header-size: 10240
+logging:
+ level:
+ root: error
+ cn.stylefeng: debug
+
spring:
application:
name: guns
@@ -54,10 +59,6 @@ mybatis-plus:
id-type: assign_id
table-underline: true
-# 是否开启websocket推送消息
-web-socket:
- open: true
-
# 单点登录开关
sso:
openFlag: false
diff --git a/src/main/webapp/assets/expand/module/webSocket/webSocket.js b/src/main/webapp/assets/expand/module/webSocket/webSocket.js
index be271fb9..be2b2047 100644
--- a/src/main/webapp/assets/expand/module/webSocket/webSocket.js
+++ b/src/main/webapp/assets/expand/module/webSocket/webSocket.js
@@ -50,7 +50,11 @@ layui.define(['jquery', 'layer'], function (exports) {
_self.heartCheckHandler = setTimeout(function () {
try {
// 发送心跳检测
- _self.send("&")
+ let heartMsg = {
+ "type": "299999",
+ "data": new Date().getMilliseconds()
+ };
+ _self.send(JSON.stringify(heartMsg))
} catch (e) {
(param.connectErr || emptyFun)(e);
_self.lockReconnect = false;
diff --git a/src/main/webapp/pages/index.html b/src/main/webapp/pages/index.html
index 053c882d..90c5d452 100644
--- a/src/main/webapp/pages/index.html
+++ b/src/main/webapp/pages/index.html
@@ -37,14 +37,40 @@
var Feng = {
ctxPath: "${ctxPath}",
version: '${constants.getReleaseVersion()}',
- wsUrl: '${wsUrl}'
+ wsUrl: '${wsUrl}',
+ userId: '${userId}'
};