+ websocket = null,
+ protocols = "base64";
+
+ var bt = false,
+ wsbt = false;
+
+ if (('Uint8Array' in window) &&
+ ('set' in Uint8Array.prototype)) {
+ bt = true;
+ }
+ // TODO: this sucks, the property should exist on the prototype
+ // but it does not.
+ try {
+ if (bt && ('binaryType' in (new WebSocket("ws://localhost:17523")))) {
+ wsbt = true;
+ }
+ } catch (exc) {
+ // Just ignore failed test localhost connections
+ }
+ if (bt && wsbt) {
+ Util.Info("Detected binaryType support in WebSockets");
+ protocols = ['binary', 'base64'];
+ } else {
+ Util.Info("No binaryType support in WebSockets, using base64 encoding");
+ protocols = 'base64';
+ }