|
|
@@ -178,12 +178,20 @@
|
|
|
playsinline
|
|
|
:muted="true"
|
|
|
></video> -->
|
|
|
- <video
|
|
|
+ <!-- <video
|
|
|
style="width: 100%; height: 100%"
|
|
|
:ref="idName1"
|
|
|
autoplay
|
|
|
playsinline
|
|
|
:muted="true"
|
|
|
+ ></video> -->
|
|
|
+
|
|
|
+ <video
|
|
|
+ style="width: 100%; height: 100%"
|
|
|
+ :ref="idName"
|
|
|
+ autoplay
|
|
|
+ playsinline
|
|
|
+ :muted="true"
|
|
|
></video>
|
|
|
</div>
|
|
|
|
|
|
@@ -196,12 +204,20 @@
|
|
|
playsinline
|
|
|
:muted="true"
|
|
|
></video> -->
|
|
|
- <video
|
|
|
+ <!-- <video
|
|
|
style="width: 100%; height: 100%"
|
|
|
:ref="idName"
|
|
|
autoplay
|
|
|
playsinline
|
|
|
:muted="true"
|
|
|
+ ></video> -->
|
|
|
+
|
|
|
+ <video
|
|
|
+ style="width: 100%; height: 100%"
|
|
|
+ :ref="idName1"
|
|
|
+ autoplay
|
|
|
+ playsinline
|
|
|
+ :muted="true"
|
|
|
></video>
|
|
|
</div>
|
|
|
|
|
|
@@ -414,12 +430,21 @@ export default {
|
|
|
url:
|
|
|
// "ws://192.168.1.17:12345/api/api_gateway?method=control_center.real_time.im_message",
|
|
|
"ws" +
|
|
|
+ // "https" +
|
|
|
this.$wsUrl +
|
|
|
"/api/api_gateway?method=control_center.real_time.im_message",
|
|
|
websock: null,
|
|
|
getUserObj: {}, // 获取到当前点击的行数据
|
|
|
msgList: [], //当前点击的账号消息列表
|
|
|
userName: "",
|
|
|
+
|
|
|
+ // 心跳、重连机制
|
|
|
+ ws: null, //建立的连接
|
|
|
+ lockReconnect: false, //是否真正建立连接
|
|
|
+ timeout: 5 * 1000, //30秒一次心跳
|
|
|
+ timeoutObj: null, //心跳心跳倒计时
|
|
|
+ serverTimeoutObj: null, //心跳倒计时
|
|
|
+ timeoutnum: null, //断开 重连倒计时
|
|
|
};
|
|
|
},
|
|
|
//监听属性 类似于data概念
|
|
|
@@ -752,6 +777,7 @@ export default {
|
|
|
},
|
|
|
};
|
|
|
this.websock.send(JSON.stringify(obj1));
|
|
|
+ // this.start(); //开启心跳
|
|
|
};
|
|
|
this.websock.onmessage = (event) => {
|
|
|
// console.log("WebSocket:消息");
|
|
|
@@ -813,10 +839,12 @@ export default {
|
|
|
this.websock.onerror = (event) => {
|
|
|
console.log("WebSocket:发生错误 ");
|
|
|
console.log(event);
|
|
|
+ // that.reconnect(); // 重连
|
|
|
};
|
|
|
this.websock.onclose = (event) => {
|
|
|
console.log("WebSocket:已关闭");
|
|
|
console.log(event);
|
|
|
+ // that.reconnect(); // 重连
|
|
|
};
|
|
|
}
|
|
|
},
|
|
|
@@ -929,6 +957,73 @@ export default {
|
|
|
console.log("不兼容");
|
|
|
}
|
|
|
},
|
|
|
+
|
|
|
+ // 心跳机制
|
|
|
+ start() {
|
|
|
+ //开启心跳
|
|
|
+ var self = this;
|
|
|
+ self.timeoutObj && clearTimeout(self.timeoutObj);
|
|
|
+ self.serverTimeoutObj && clearTimeout(self.serverTimeoutObj);
|
|
|
+ self.timeoutObj = setTimeout(function () {
|
|
|
+ //这里发送一个心跳,后端收到后,返回一个心跳消息,
|
|
|
+ console.log("心跳中。。。", self.websock.readyState);
|
|
|
+ // if (self.websock.readyState == 1) {
|
|
|
+ // //如果连接正常
|
|
|
+ // self.websock.send(
|
|
|
+ // JSON.stringify({
|
|
|
+ // data: {
|
|
|
+ // action: "list",
|
|
|
+ // recv_user_id: '',
|
|
|
+ // data: {
|
|
|
+ // msg_status: false,
|
|
|
+ // msg_info: "",
|
|
|
+ // },
|
|
|
+ // },
|
|
|
+ // })
|
|
|
+ // );
|
|
|
+ // } else {
|
|
|
+ // //否则重连
|
|
|
+ // self.reconnect();
|
|
|
+ // }
|
|
|
+ //如果连接正常
|
|
|
+ var obj1 = {};
|
|
|
+ obj1 = {
|
|
|
+ action: "list",
|
|
|
+ recv_user_id: "",
|
|
|
+ data: {
|
|
|
+ msg_status: false,
|
|
|
+ msg_info: "",
|
|
|
+ },
|
|
|
+ };
|
|
|
+ self.websock.send(JSON.stringify(obj1));
|
|
|
+ // self.serverTimeoutObj = setTimeout(function () {
|
|
|
+ // //超时关闭
|
|
|
+ // self.websock.close();
|
|
|
+ // }, self.timeout);
|
|
|
+ }, self.timeout);
|
|
|
+ },
|
|
|
+ reset() {
|
|
|
+ //重置心跳
|
|
|
+ var that = this;
|
|
|
+ clearTimeout(that.timeoutObj); //清除时间
|
|
|
+ clearTimeout(that.serverTimeoutObj); //清除时间
|
|
|
+ // that.start(); //重启心跳
|
|
|
+ },
|
|
|
+
|
|
|
+ // 重连机制
|
|
|
+ reconnect() {
|
|
|
+ var that = this;
|
|
|
+ if (that.lockReconnect) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ that.lockReconnect = true;
|
|
|
+ // 没连接上会一直重连,设置延迟避免请求过多
|
|
|
+ that.timeoutnum && clearTimeout(that.timeoutnum);
|
|
|
+ that.timeoutnum = setTimeout(function () {
|
|
|
+ that.msgInit(); //新连接
|
|
|
+ that.lockReconnect = false;
|
|
|
+ }, 5000);
|
|
|
+ },
|
|
|
},
|
|
|
//生命周期 - 创建完成(可以访问当前this实例)
|
|
|
created() {
|
|
|
@@ -943,9 +1038,9 @@ export default {
|
|
|
// this.loading2 = true;
|
|
|
// this.organizationData(); //获取左侧组织列表
|
|
|
// this.userListData(); // 获取右侧用户列表
|
|
|
- console.log("---------------------------");
|
|
|
- console.log(this.websock);
|
|
|
- console.log("---------------------------");
|
|
|
+ // console.log("---------------------------");
|
|
|
+ // console.log(this.websock);
|
|
|
+ // console.log("---------------------------");
|
|
|
if (this.websock == null) {
|
|
|
this.msgInit(); // 文本消息功能初始化
|
|
|
}
|