summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS.md5
-rw-r--r--web_socket.js14
2 files changed, 16 insertions, 3 deletions
diff --git a/NEWS.md b/NEWS.md
index ebdff16..42caa9c 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,3 +1,8 @@
+- 2011-12-17
+ - web-socket-js now uses MozWebSocket when available. i.e. When you load
+ web_socket.js, WebSocket is defined as alias of MozWebSocket when
+ available.
+
- 2011-09-18
- web-socket-js now speaks WebSocket version hybi-10. Old versions spoke
hixie-76. If you really need web-socket-js which speaks hixie-76, you can
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;