diff options
author | Hiroshi Ichikawa <gimite@gmail.com> | 2011-12-17 20:06:26 +0900 |
---|---|---|
committer | Hiroshi Ichikawa <gimite@gmail.com> | 2011-12-17 20:06:26 +0900 |
commit | b16e4ce91f938d45aa7a3b0ca89abec39f4c8518 (patch) | |
tree | 5219c2aa97bff7749f7a52f25901f609284b32e4 /web_socket.js | |
parent | 841b01d9f1f8620af349642d5a7f9ab7f0769c17 (diff) | |
download | web-socket-js-b16e4ce91f938d45aa7a3b0ca89abec39f4c8518.tar.gz |
Using MozWebSocket when available. Issue #87
Diffstat (limited to 'web_socket.js')
-rw-r--r-- | web_socket.js | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/web_socket.js b/web_socket.js index 0037d68..6b629a6 100644 --- a/web_socket.js +++ b/web_socket.js @@ -5,7 +5,15 @@ (function() { - if (window.WebSocket && !window.WEB_SOCKET_FORCE_FLASH) return; + if (window.WEB_SOCKET_FORCE_FLASH) { + // Keeps going. + } else if (window.WebSocket) { + return; + } else if (window.MozWebSocket) { + // Firefox. + window.WebSocket = MozWebSocket; + return; + } var logger; if (window.WEB_SOCKET_LOGGER) { @@ -30,14 +38,14 @@ } /** - * This class represents a faux web socket. + * Our own implementation of WebSocket class using Flash. * @param {string} url * @param {array or string} protocols * @param {string} proxyHost * @param {int} proxyPort * @param {string} headers */ - WebSocket = function(url, protocols, proxyHost, proxyPort, headers) { + window.WebSocket = function(url, protocols, proxyHost, proxyPort, headers) { var self = this; self.__id = WebSocket.__nextId++; WebSocket.__instances[self.__id] = self; |