Check for connection state before sending flush character

This commit is contained in:
Sebastian Serth
2020-11-11 18:16:07 +01:00
parent 6868102071
commit 08278fa4e9

View File

@ -4,8 +4,10 @@ CommandSocket = function(url, onOpen) {
this.websocket.onopen = onOpen; this.websocket.onopen = onOpen;
this.websocket.onmessage = this.onMessage.bind(this); this.websocket.onmessage = this.onMessage.bind(this);
this.websocket.flush = function () { this.websocket.flush = function () {
if (this.readyState === this.OPEN) {
this.send('\n'); this.send('\n');
} }
}
}; };
CommandSocket.prototype.onError = function(callback){ CommandSocket.prototype.onError = function(callback){