Commit ec54df06 authored by 以墨为白's avatar 以墨为白 🎧

心跳

parent 5839a104
......@@ -78,17 +78,27 @@ export default {
this.stompClient = Stomp.over(this.ws);
this.stompClient.heartbeat.outgoing = 20000; //若使用STOMP 1.1 版本,默认开启了心跳检测机制(默认值都是10000ms)
this.stompClient.heartbeat.incoming = 20000; //客户端不从服务端接收心跳包
this.stompClient.debug = null;
this.stompClient.connect({ name: this.userInfo.account }, frame => {
resolve("连接成功")
// resolve("连接成功")
}, err => {
debugger
console.log(typeof err == "string" ? err : err.headers.message)
reject(typeof err == "string" ? err : err.headers.message)
});
})
},
reconnect(){
if (this._lockReconnect) return;
this._lockReconnect = true;
let self = this;
setTimeout(() => {
this.connect().catch(err=>{
self.reconnect();
});
self._lockReconnect = false;
}, 5000);
},
searchChatList() {
this.queryChatRoomListFn({ startTime: this.form.dateRange&&this.form.dateRange.length > 0 ? this.form.dateRange[0] : '2023-01-01 00:00:00', endTime: this.form.dateRange&&this.form.dateRange.length > 0 ? this.form.dateRange[1] : getTime_extent(0).pre_rq_end, userId: this.userInfo.account, keyword: this.form.keyWord == '' ? null : this.form.keyWord });
},
......@@ -104,10 +114,14 @@ export default {
},
mounted() {
this.queryChatRoomListFn({ userId: this.userInfo.account });
this.connect();
this.connect().catch(err=>{
this.reconnect();
});
},
destroyed() {
this.ws.onclose();
//手动断开
this.stompClient.disconnect();
this.ws.close();
}
}
</script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment