From bee36506e1b6d70109e540697ec17c6da75000f7 Mon Sep 17 00:00:00 2001 From: Joel Martin Date: Fri, 8 Jun 2012 10:42:26 -0500 Subject: [PATCH] Fix forcing of web-socket-js even when native available. --- include/web-socket-js/web_socket.js | 2 +- include/websock.js | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/include/web-socket-js/web_socket.js b/include/web-socket-js/web_socket.js index ec2a8b72..a1330133 100644 --- a/include/web-socket-js/web_socket.js +++ b/include/web-socket-js/web_socket.js @@ -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) { diff --git a/include/websock.js b/include/websock.js index 33350df0..69b58f4e 100644 --- a/include/websock.js +++ b/include/websock.js @@ -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) { @@ -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() { @@ -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");