Skip to content

Commit

Permalink
allow to skip WAMP subprotocol announce - fixes issue crossbario#16
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Oberstein committed Mar 11, 2013
1 parent 57c3260 commit 4f8bf11
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions autobahn/autobahn.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,10 +326,18 @@ ab._Deferred = when.defer;
ab._construct = function (url, protocols) {
if ("WebSocket" in window) {
// Chrome, MSIE, newer Firefox
return new WebSocket(url, protocols);
if (protocols) {
return new WebSocket(url, protocols);
} else {
return new WebSocket(url);
}
} else if ("MozWebSocket" in window) {
// older versions of Firefox prefix the WebSocket object
return new MozWebSocket(url, protocols);
if (protocols) {
return new MozWebSocket(url, protocols);
} else {
return new MozWebSocket(url);
}
} else {
return null;
}
Expand Down Expand Up @@ -358,7 +366,12 @@ ab.Session = function (wsuri, onopen, onclose, options) {
self._txcnt = 0;
self._rxcnt = 0;

self._websocket = ab._construct(self._wsuri, [ab._subprotocol]);
if (self._options && self._options.skipSubprotocolAnnounce) {
self._websocket = ab._construct(self._wsuri);
} else {
self._websocket = ab._construct(self._wsuri, [ab._subprotocol]);
}

if (!self._websocket) {
if (onclose !== undefined) {
onclose(ab.CONNECTION_UNSUPPORTED);
Expand Down Expand Up @@ -991,6 +1004,10 @@ ab.connect = function (wsuri, onconnect, onhangup, options) {
peer.options.skipSubprotocolCheck = false;
}

if (peer.options.skipSubprotocolAnnounce == undefined) {
peer.options.skipSubprotocolAnnounce = false;
}

if (!onconnect) {
throw "onConnect handler required!";
} else {
Expand Down

0 comments on commit 4f8bf11

Please sign in to comment.