Send WebSocket messages only if connected

This commit is contained in:
Sebastian Serth
2020-10-29 12:45:40 +01:00
parent 51188eb72a
commit 1a20c70c41

View File

@ -86,7 +86,11 @@ CommandSocket.prototype.executeCommand = function(cmd) {
* @param data
*/
CommandSocket.prototype.send = function(data) {
this.websocket.send(data);
// Only send message if WebSocket is open and ready.
// Ignore all other messages (they might hit a wrong container anyway)
if (this.getReadyState() === this.websocket.OPEN) {
this.websocket.send(data);
}
};
/**