纠错:unisocket 在 reconnecting 时,需要继续把 url 做参数
This commit is contained in:
parent
dcc8e47656
commit
c5d5b2d4e6
@ -21,14 +21,14 @@ module.exports={
|
||||
console.log('Websocket onClose: ', res)
|
||||
if (!my.reconnecting)
|
||||
my.reconnecting = setInterval(()=>{
|
||||
console.log(new Date(), 'WebSocket reconnecting...')
|
||||
this.initSocket()
|
||||
console.log(new Date().toJSON(), 'WebSocket reconnecting...')
|
||||
this.initSocket(url)
|
||||
}, 5000) // 每5秒尝试重连
|
||||
})
|
||||
my.socket.onError((err)=>{
|
||||
console.log('Websocket onError: ', err)
|
||||
})
|
||||
my.socket.onMessage(({data})=>{ // 在这里统一分发消息
|
||||
my.socket.onMessage(({data})=>{ // 在这里统一分发消息(用户端通常不需要返回结果给服务器,因此不用 rpc 模式,而用 event 模式。
|
||||
try {
|
||||
let dataObj = JSON.parse(data)
|
||||
console.log('WebSocket onMessage for skevent: ', dataObj.skevent)
|
||||
@ -37,7 +37,7 @@ module.exports={
|
||||
listener(dataObj)
|
||||
}
|
||||
}catch(exception){
|
||||
console.log(new Date(), 'unknown message', data)
|
||||
console.log(new Date().toJSON(), 'unknown message', data)
|
||||
return
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user