From 25a7e8a33b2ea7d4126ebfa6ed29d7f992edcd6b Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Wed, 2 Sep 2020 23:57:37 +0200 Subject: [PATCH] bugfix: check websocket before send requests Signed-off-by: Stefan Dej --- src/plugins/wsClient.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/plugins/wsClient.js b/src/plugins/wsClient.js index 8cd1de12..b3e3bbe9 100644 --- a/src/plugins/wsClient.js +++ b/src/plugins/wsClient.js @@ -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)); + } } }