Send WebSocket messages only if connected
This commit is contained in:
@ -86,7 +86,11 @@ CommandSocket.prototype.executeCommand = function(cmd) {
|
|||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
CommandSocket.prototype.send = function(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);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user