diff options
author | Hiroshi Ichikawa <gimite@gmail.com> | 2011-05-07 11:01:51 +0900 |
---|---|---|
committer | Hiroshi Ichikawa <gimite@gmail.com> | 2011-05-07 11:01:51 +0900 |
commit | fd5fa42d4428b766c28b87c64c8c67162974b9f0 (patch) | |
tree | ac76139a569356dc39b96f806955e13e9daa0d3f /web_socket.js | |
parent | 9e67e24ba3af73fda6fd7adabe95d37ef8ca50e2 (diff) | |
parent | 3cc9cdc9cf62bd3e2b60b375c6ac5b7a008956dd (diff) | |
download | web-socket-js-fd5fa42d4428b766c28b87c64c8c67162974b9f0.tar.gz |
Merging.
Diffstat (limited to 'web_socket.js')
-rw-r--r-- | web_socket.js | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/web_socket.js b/web_socket.js index 5f359d3..1cf0249 100644 --- a/web_socket.js +++ b/web_socket.js @@ -26,24 +26,29 @@ /** * This class represents a faux web socket. * @param {string} url - * @param {string} protocol + * @param {array or string} protocols * @param {string} proxyHost * @param {int} proxyPort * @param {string} headers */ - WebSocket = function(url, protocol, proxyHost, proxyPort, headers) { + WebSocket = function(url, protocols, proxyHost, proxyPort, headers) { var self = this; self.__id = WebSocket.__nextId++; WebSocket.__instances[self.__id] = self; self.readyState = WebSocket.CONNECTING; self.bufferedAmount = 0; self.__events = {}; + if (!protocols) { + protocols = []; + } else if (typeof protocols == "string") { + protocols = [protocols]; + } // Uses setTimeout() to make sure __createFlash() runs after the caller sets ws.onopen etc. // Otherwise, when onopen fires immediately, onopen is called before it is set. setTimeout(function() { WebSocket.__addTask(function() { WebSocket.__flash.create( - self.__id, url, protocol, proxyHost || null, proxyPort || 0, headers || null); + self.__id, url, protocols, proxyHost || null, proxyPort || 0, headers || null); }); }, 0); }; |