summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsamhed <samuel@cendio.se>2014-08-19 13:49:55 +0200
committersamhed <samuel@cendio.se>2014-08-19 13:49:55 +0200
commit960752ea5308ea5aacd5a350b2ad45dcf999a608 (patch)
tree658c169522b0502a89a441847f28780c54301029
parent9b731d3a5811cce05001e1d8fbb0d53e2859c86b (diff)
downloadnovnc-960752ea5308ea5aacd5a350b2ad45dcf999a608.tar.gz
fixes an error that was made in the merge with the last sync with websockify.
-rw-r--r--include/websock.js16
1 files changed, 9 insertions, 7 deletions
diff --git a/include/websock.js b/include/websock.js
index 01a24c3..0e4718a 100644
--- a/include/websock.js
+++ b/include/websock.js
@@ -262,7 +262,7 @@ function on(evt, handler) {
eventHandlers[evt] = handler;
}
-function init(protocols) {
+function init(protocols, ws_schema) {
rQ = [];
rQi = 0;
sQ = [];
@@ -277,12 +277,13 @@ function init(protocols) {
('set' in Uint8Array.prototype)) {
bt = true;
}
-
- // Check for full binary type support in WebSockets
- // TODO: this sucks, the property should exist on the prototype
- // but it does not.
+ // Check for full binary type support in WebSocket
+ // Inspired by:
+ // https://github.com/Modernizr/Modernizr/issues/370
+ // https://github.com/Modernizr/Modernizr/blob/master/feature-detects/websockets/binary.js
try {
- if (bt && ('binaryType' in (new WebSocket("ws://localhost:17523")))) {
+ if (bt && ('binaryType' in WebSocket.prototype ||
+ !!(new WebSocket(ws_schema + '://.').binaryType))) {
Util.Info("Detected binaryType support in WebSockets");
wsbt = true;
}
@@ -325,7 +326,8 @@ function init(protocols) {
}
function open(uri, protocols) {
- protocols = init(protocols);
+ var ws_schema = uri.match(/^([a-z]+):\/\//)[1];
+ protocols = init(protocols, ws_schema);
if (test_mode) {
websocket = {};