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,7 +4,9 @@ CommandSocket = function(url, onOpen) {
this.websocket.onopen = onOpen;
this.websocket.onmessage = this.onMessage.bind(this);
this.websocket.flush = function () {
this.send('\n');
if (this.readyState === this.OPEN) {
this.send('\n');
}
}
};