Skip to content

Commit

Permalink
Fix forcing of web-socket-js even when native available.
Browse files Browse the repository at this point in the history
  • Loading branch information
kanaka committed Jun 8, 2012
1 parent cb3ad1b commit bee3650
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion include/web-socket-js/web_socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

(function() {

if (window.WebSocket) return;
if (window.WebSocket && !window.WEB_SOCKET_FORCE_FLASH) return;

var console = window.console;
if (!console || !console.log || !console.error) {
Expand Down
10 changes: 7 additions & 3 deletions include/websock.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@

// Load Flash WebSocket emulator if needed

// To force WebSocket emulator even when native WebSocket available
window.WEB_SOCKET_FORCE_FLASH = true;
// To enable WebSocket emulator debug:
window.WEB_SOCKET_DEBUG=1;

if (window.WebSocket && !window.WEB_SOCKET_FORCE_FLASH) {
Websock_native = true;
} else if (window.MozWebSocket && !window.WEB_SOCKET_FORCE_FLASH) {
Expand All @@ -28,9 +33,6 @@ if (window.WebSocket && !window.WEB_SOCKET_FORCE_FLASH) {
} else {
/* no builtin WebSocket so load web_socket.js */

// To enable debug:
// window.WEB_SOCKET_DEBUG=1;

Websock_native = false;
(function () {
function get_INCLUDE_URI() {
Expand Down Expand Up @@ -280,6 +282,8 @@ function open(uri) {
Util.Debug(">> WebSock.onopen");
if (websocket.protocol) {
Util.Info("Server chose sub-protocol: " + websocket.protocol);
} else {
Util.Error("Server select no sub-protocol!: " + websocket.protocol);
}
eventHandlers.open();
Util.Debug("<< WebSock.onopen");
Expand Down

0 comments on commit bee3650

Please sign in to comment.