Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Using MozWebSocket when available. Issue #87

  • Loading branch information...
commit b16e4ce91f938d45aa7a3b0ca89abec39f4c8518 1 parent 841b01d
@gimite authored
Showing with 16 additions and 3 deletions.
  1. +5 −0 NEWS.md
  2. +11 −3 web_socket.js
View
5 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
View
14 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;
Please sign in to comment.
Something went wrong with that request. Please try again.