Fix occasional error with sending while readyState !== 1

Under certain conditions, noVNC would attempt to flush the web socket
while it was disconnected, before the disconnected state was picked up.
This casues noVNC to crash ungracefully and the parent window is not
notified - leading to no chance at recovery without a page refresh.
This commit is contained in:
Drew DeVault 2015-07-30 10:13:35 -04:00 committed by Abe Massry
parent 8f3c0f6b9b
commit d9728940d2
1 changed files with 1 additions and 1 deletions

View File

@ -175,7 +175,7 @@ function Websock() {
}
if (this._websocket.bufferedAmount < this.maxBufferedAmount) {
if (this._sQ.length > 0) {
if (this._sQ.length > 0 && this._websocket.readyState === 1) {
this._websocket.send(this._encode_message());
this._sQ = [];
}