Skip to content

Commit 33a05dc

Browse files
committed
Check WebSocket status before sending
1 parent f20b337 commit 33a05dc

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

timeflux_ui/www/common/assets/js/timeflux.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,9 @@ class IO {
200200
* @returns {boolean}
201201
*/
202202
send(command, payload) {
203-
try{
204-
let message = JSON.stringify({command: command, payload: payload});
205-
this.socket.send(message);
206-
} catch {
207-
return false;
208-
}
203+
if (this.socket.readyState !== this.socket.OPEN) return false;
204+
let message = JSON.stringify({command: command, payload: payload});
205+
this.socket.send(message);
209206
return true;
210207
}
211208

0 commit comments

Comments
 (0)