summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Mannehed <samuel@samuel-xps13.lan>2016-04-30 02:33:06 +0200
committerSamuel Mannehed <samuel@samuel-xps13.lan>2016-04-30 02:34:20 +0200
commit3120c9b5ec1e78d41490afc6115e96644ebd8391 (patch)
tree8cf96b78f426057eff4d967ddc82e2d12d1f7278
parent32df3fdbe1b289b06344902b72537d6dc3671afb (diff)
parentcf0623fffa6db5a27782998a610690f9b27605bc (diff)
downloadnovnc-3120c9b5ec1e78d41490afc6115e96644ebd8391.tar.gz
Merge branch 'SirCmpwn-fix-send-on-disconnect'
Updated patch to use the readyState constant even in the tests.
-rw-r--r--include/websock.js2
-rw-r--r--tests/test.websock.js1
2 files changed, 2 insertions, 1 deletions
diff --git a/include/websock.js b/include/websock.js
index f3336a0..4d7a4f9 100644
--- a/include/websock.js
+++ b/include/websock.js
@@ -197,7 +197,7 @@ function Websock() {
}
if (this._websocket.bufferedAmount < this.maxBufferedAmount) {
- if (this._sQlen > 0) {
+ if (this._sQlen > 0 && this._websocket.readyState === WebSocket.OPEN) {
this._websocket.send(this._encode_message());
this._sQlen = 0;
}
diff --git a/tests/test.websock.js b/tests/test.websock.js
index 953a526..f708e04 100644
--- a/tests/test.websock.js
+++ b/tests/test.websock.js
@@ -173,6 +173,7 @@ describe('Websock', function() {
it('should actually send on the websocket if the websocket does not have too much buffered', function () {
sock.maxBufferedAmount = 10;
sock._websocket.bufferedAmount = 8;
+ sock._websocket.readyState = WebSocket.OPEN
sock._sQ = new Uint8Array([1, 2, 3]);
sock._sQlen = 3;
var encoded = sock._encode_message();