fix
This commit is contained in:
@@ -8,6 +8,7 @@ class MyWs {
|
||||
this.messageUrl = http+'/notification'
|
||||
this.wsUrl = ''
|
||||
this.reconnectionTime = null
|
||||
this.times = 0
|
||||
}
|
||||
linkWs(url) {
|
||||
if(!(JSON.parse(getCookie("userInfo"))))return
|
||||
@@ -17,6 +18,7 @@ class MyWs {
|
||||
this.ws.onmessage = (e)=>{
|
||||
try {
|
||||
MyWs.receiveText(JSON.parse(e.data))
|
||||
this.times = 0
|
||||
} catch (error) {
|
||||
console.error('websocket',error)
|
||||
}
|
||||
@@ -32,7 +34,9 @@ class MyWs {
|
||||
}
|
||||
}
|
||||
reconnection(){
|
||||
this.times++
|
||||
clearTimeout(this.reconnectionTime)
|
||||
if(this.times>=10)return
|
||||
this.reconnectionTime = setTimeout(()=>{
|
||||
this.linkWs(this.wsUrl)
|
||||
},1000)
|
||||
|
||||
Reference in New Issue
Block a user