|
@@ -76,7 +76,8 @@ export default {
|
|
require('@/assets/img/icon_msg7.png'),
|
|
require('@/assets/img/icon_msg7.png'),
|
|
require('@/assets/img/icon_msg8.png'),
|
|
require('@/assets/img/icon_msg8.png'),
|
|
require('@/assets/img/icon_msg9.png')
|
|
require('@/assets/img/icon_msg9.png')
|
|
- ]
|
|
|
|
|
|
+ ],
|
|
|
|
+ websocket: ''
|
|
};
|
|
};
|
|
},
|
|
},
|
|
components: {
|
|
components: {
|
|
@@ -206,6 +207,7 @@ export default {
|
|
initWebSocket(id) {
|
|
initWebSocket(id) {
|
|
if ('WebSocket' in window) {
|
|
if ('WebSocket' in window) {
|
|
var serviceIp = this.envConfig.websoketUrl;
|
|
var serviceIp = this.envConfig.websoketUrl;
|
|
|
|
+
|
|
this.websocket = new WebSocket('ws://' + serviceIp + '/sc-message/webSocket/' + id);
|
|
this.websocket = new WebSocket('ws://' + serviceIp + '/sc-message/webSocket/' + id);
|
|
} else {
|
|
} else {
|
|
console.log('当前浏览器 Not support websocket');
|
|
console.log('当前浏览器 Not support websocket');
|
|
@@ -213,9 +215,10 @@ export default {
|
|
let that = this;
|
|
let that = this;
|
|
this.interval = window.setInterval(function () {
|
|
this.interval = window.setInterval(function () {
|
|
//每隔30秒钟发送一次心跳,避免websocket连接因超时而自动断开
|
|
//每隔30秒钟发送一次心跳,避免websocket连接因超时而自动断开
|
|
|
|
+
|
|
if (that.websocket != null) {
|
|
if (that.websocket != null) {
|
|
- // that.websocket.send('HeartBeat');
|
|
|
|
- // console.log('发送心跳包:HeartBeat');
|
|
|
|
|
|
+ // that.websocket.send();
|
|
|
|
+ console.log('发送心跳包:HeartBeat');
|
|
}
|
|
}
|
|
}, 30000);
|
|
}, 30000);
|
|
//连接发生错误的回调方法
|
|
//连接发生错误的回调方法
|
|
@@ -231,6 +234,7 @@ export default {
|
|
|
|
|
|
//接收到消息的回调方法
|
|
//接收到消息的回调方法
|
|
this.websocket.onmessage = function (event) {
|
|
this.websocket.onmessage = function (event) {
|
|
|
|
+ debugger;
|
|
let msg = JSON.parse(event.data);
|
|
let msg = JSON.parse(event.data);
|
|
let i = msg.typeId - 1;
|
|
let i = msg.typeId - 1;
|
|
if (msg.userId) {
|
|
if (msg.userId) {
|