bugfix: check websocket before send requests

Signed-off-by: Stefan Dej <meteyou@gmail.com>
This commit is contained in:
Stefan Dej committed 2020-09-02 23:57:37 +02:00
1 parent 8b8f3cf939
commit 25a7e8a33b
1 file changed
+9 -7
+9 -7
View File
@@ -86,12 +86,14 @@ export default class WebSocketClient {
}
sendObj (method, params, action = '') {
let id = Math.floor(Math.random() * 10000) + 1
this.wsData.push({
id: id,
action: action,
params: params
})
this.instance.send(this.createMessage(method, params, id))
if (this.instance.readyState === WebSocket.OPEN) {
let id = Math.floor(Math.random() * 10000) + 1
this.wsData.push({
id: id,
action: action,
params: params
})
this.instance.send(this.createMessage(method, params, id));
}
}
}