|
@@ -503,7 +503,11 @@ linezhexian(num){
|
|
|
if(canshu==''){
|
|
|
setTimeout(function(){
|
|
|
that.initWebSocket();
|
|
|
- },500)
|
|
|
+ // this.startimg("init",'loaddata');
|
|
|
+ },300)
|
|
|
+ setTimeout(function(){
|
|
|
+ that.startimg("init",'loaddata');
|
|
|
+ },1000)
|
|
|
}
|
|
|
})
|
|
|
}else if(val=='FEMLab(结构力学)'){
|
|
@@ -713,43 +717,48 @@ let params = {
|
|
|
},
|
|
|
// 心跳包
|
|
|
reconnect(){
|
|
|
- // var that=this;
|
|
|
- // if(that.lockReconnect) return;
|
|
|
- // that.lockReconnect = true;
|
|
|
- // //没连接上会一直重连,设置延迟避免请求过多
|
|
|
- // that.timeoutnum&&clearTimeout(that.timeoutnum);
|
|
|
- // that.timeoutnum= setTimeout(function () {
|
|
|
- // //新连接
|
|
|
- // this.initWebSocket();
|
|
|
- // that.lockReconnect = false;
|
|
|
- // },5000);
|
|
|
+ var that=this;
|
|
|
+ if(that.lockReconnect) return;
|
|
|
+ that.lockReconnect = true;
|
|
|
+ //没连接上会一直重连,设置延迟避免请求过多
|
|
|
+ that.timeoutnum&&clearTimeout(that.timeoutnum);
|
|
|
+ that.timeoutnum= setTimeout(function () {
|
|
|
+ //新连接
|
|
|
+ this.initWebSocket();
|
|
|
+ that.lockReconnect = false;
|
|
|
+ },5000);
|
|
|
},
|
|
|
reset(){//重置心跳
|
|
|
-// var that=this;
|
|
|
-// clearTimeout(this.timeoutObj);
|
|
|
-// clearTimeout(this.serverTimeoutObj);
|
|
|
-// that.start();
|
|
|
+ var that=this;
|
|
|
+ clearTimeout(this.timeoutObj);
|
|
|
+ clearTimeout(this.serverTimeoutObj);
|
|
|
+ that.start();
|
|
|
},
|
|
|
start(){//开启心跳
|
|
|
- // console.log(11111)
|
|
|
- // var self = this;
|
|
|
- // self.timeoutObj&&clearTimeout(self.timeoutObj);
|
|
|
- // self.serverTimeoutObj&&clearTimeout(self.serverTimeoutObj);
|
|
|
- // self.timeoutObj = setTimeout(function(){
|
|
|
- // self.ws.send("heartCheck");
|
|
|
- // //这里发送一个心跳,后端收到后,返回一个心跳消息
|
|
|
- // // if(self.ws.readyState==1){//如果连接正常
|
|
|
- // // self.ws.send("heartCheck");
|
|
|
- // // }else{//否则重连
|
|
|
- // // self.reconnect()
|
|
|
- // // }
|
|
|
- // self.serverTimeoutObj = setTimeout(function(){
|
|
|
- // // 超时关闭
|
|
|
- // self.ws.close();//如果onclose会执行reconnect,我们执行ws.close()就行了.如果直接执行reconnect 会触发onclose导致重连两次
|
|
|
- // }, self.timeout)
|
|
|
- // }, this.timeout)
|
|
|
+ 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("heartCheck");
|
|
|
+ }else{//否则重连
|
|
|
+ self.reconnect()
|
|
|
+ }
|
|
|
+ self.serverTimeoutObj = setTimeout(function(){
|
|
|
+ // 超时关闭
|
|
|
+ self.websock.close();//如果onclose会执行reconnect,我们执行ws.close()就行了.如果直接执行reconnect 会触发onclose导致重连两次
|
|
|
+ }, self.timeout)
|
|
|
+ }, this.timeout)
|
|
|
},
|
|
|
// },
|
|
|
+beforeDestroy() {
|
|
|
+ this.websock.close()
|
|
|
+ // 清除时间
|
|
|
+ clearTimeout(this.timeoutObj)
|
|
|
+ clearTimeout(this.serverTimeoutObj)
|
|
|
+},
|
|
|
// // 文件渲染websoket图片的渲染
|
|
|
initWebSocket(){ //初始化weosocket
|
|
|
|
|
@@ -764,8 +773,7 @@ reconnect(){
|
|
|
|
|
|
},
|
|
|
websocketonopen(e){ //连接建立之后执行send方法发送数据
|
|
|
- this.startimg("init",'loaddata');
|
|
|
- console.log(e);
|
|
|
+ // this.startimg("init",'loaddata');
|
|
|
this.start();
|
|
|
},
|
|
|
websocketonerror(){//连接建立失败重连
|
|
@@ -773,18 +781,22 @@ reconnect(){
|
|
|
this.reconnect();
|
|
|
},
|
|
|
websocketonmessage(e){ //数据接收
|
|
|
- this.loadingopen();
|
|
|
+ console.log(e);
|
|
|
+
|
|
|
this.reset();
|
|
|
+ let data=e.data;
|
|
|
+ if(data.indexOf("heartCheck") != -1){
|
|
|
+ }else{
|
|
|
+ this.loadingopen();
|
|
|
try{
|
|
|
-
|
|
|
let eadata=e.data
|
|
|
var rdata=JSON.parse(e.data)
|
|
|
if(rdata.hasOwnProperty("img")){
|
|
|
+ this.loadingopen();
|
|
|
this.$refs.TFileStream.imgtupian=true;
|
|
|
this.$refs.TFileStream.fetchData(rdata);
|
|
|
this.$refs.monitor.container_show=false;
|
|
|
}
|
|
|
-
|
|
|
// HCFD云图的参数返回 存储
|
|
|
console.log(rdata);
|
|
|
let rdataparamJson =JSON.parse(rdata.paramJson);
|
|
@@ -816,7 +828,6 @@ reconnect(){
|
|
|
this.$refs.hcfd.streamdata(JSON.stringify(data))
|
|
|
}
|
|
|
if(data.msgType=='solidsurface_param'){
|
|
|
- //this.$refs.hcfd.colorval(JSON.stringify(data))
|
|
|
}
|
|
|
if(data.msgType=='animation_param'){
|
|
|
this.$refs.hcfd.zoomanimation(JSON.stringify(data))
|
|
@@ -889,20 +900,17 @@ reconnect(){
|
|
|
}
|
|
|
return true;
|
|
|
}catch(error){
|
|
|
- this.loadingend(this.loadingopen());
|
|
|
+ this.loadingend(this.loadingopen());
|
|
|
return false;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ }
|
|
|
},
|
|
|
websocketsend(Data){//数据发送
|
|
|
this.websock.send(Data);
|
|
|
},
|
|
|
websocketclose(e){ //关闭
|
|
|
this.websock.close();
|
|
|
- // Message({
|
|
|
- // type: "error",
|
|
|
- // message: "websock断开连接",
|
|
|
- // });
|
|
|
this.loadingend(this.loadingopen());
|
|
|
this.reconnect();
|
|
|
},
|