Skip to content

Commit

Permalink
Check WebSocket status before sending
Browse files Browse the repository at this point in the history
  • Loading branch information
mesca committed Dec 16, 2023
1 parent f20b337 commit 33a05dc
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions timeflux_ui/www/common/assets/js/timeflux.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,9 @@ class IO {
* @returns {boolean}
*/
send(command, payload) {
try{
let message = JSON.stringify({command: command, payload: payload});
this.socket.send(message);
} catch {
return false;
}
if (this.socket.readyState !== this.socket.OPEN) return false;
let message = JSON.stringify({command: command, payload: payload});
this.socket.send(message);
return true;
}

Expand Down

0 comments on commit 33a05dc

Please sign in to comment.