summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiroshi Ichikawa <gimite@gmail.com>2011-12-17 20:06:26 +0900
committerHiroshi Ichikawa <gimite@gmail.com>2011-12-17 20:06:26 +0900
commitb16e4ce91f938d45aa7a3b0ca89abec39f4c8518 (patch)
tree5219c2aa97bff7749f7a52f25901f609284b32e4
parent841b01d9f1f8620af349642d5a7f9ab7f0769c17 (diff)
downloadweb-socket-js-b16e4ce91f938d45aa7a3b0ca89abec39f4c8518.tar.gz
Using MozWebSocket when available. Issue #87
-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;