|
@@ -28,8 +28,12 @@ function handleError(err) { |
|
|
console.log('[x] 出错:', err, err.data) |
|
|
console.log('[x] 出错:', err, err.data) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function handleClose() { |
|
|
|
|
|
|
|
|
function handleClose(data) { |
|
|
console.log('[x] 服务器关闭连接') |
|
|
console.log('[x] 服务器关闭连接') |
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
|
const wsc = new WsClient(data); |
|
|
|
|
|
wsc.registerListeners(); |
|
|
|
|
|
}, 30000) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -77,7 +81,7 @@ export default class WsClient { |
|
|
if (!WsClient.socket.onopen) WsClient.socket.onopen = handleOpen |
|
|
if (!WsClient.socket.onopen) WsClient.socket.onopen = handleOpen |
|
|
if (!WsClient.socket.onmessage) WsClient.socket.onmessage = handleData.bind(this.vueInstance) |
|
|
if (!WsClient.socket.onmessage) WsClient.socket.onmessage = handleData.bind(this.vueInstance) |
|
|
if (!WsClient.socket.onerror) WsClient.socket.onerror = handleError |
|
|
if (!WsClient.socket.onerror) WsClient.socket.onerror = handleError |
|
|
if (!WsClient.socket.onclose) WsClient.socket.onclose = handleClose |
|
|
|
|
|
|
|
|
if (!WsClient.socket.onclose) WsClient.socket.onclose = handleClose(this.vueInstance) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static createSocket() { |
|
|
static createSocket() { |
|
|