diff --git a/include/web-socket-js/flash-src/WebSocketMain.as b/include/web-socket-js/flash-src/WebSocketMain.as index 8fb6b547..140241c4 100644 --- a/include/web-socket-js/flash-src/WebSocketMain.as +++ b/include/web-socket-js/flash-src/WebSocketMain.as @@ -21,6 +21,7 @@ public class WebSocketMain extends Sprite { private var policyLoaded:Boolean = false; private var callerUrl:String; + private var debug:Boolean = false; public function WebSocketMain() { @@ -42,6 +43,10 @@ public class WebSocketMain extends Sprite { callerUrl = url; } + public function setDebug(val:Boolean):void { + debug = val; + } + public function create( url:String, protocol:String, proxyHost:String = null, proxyPort:int = 0, @@ -70,7 +75,9 @@ public class WebSocketMain extends Sprite { } public function log(message:String):void { - ExternalInterface.call("webSocketLog", encodeURIComponent("[WebSocket] " + message)); + if (debug) { + ExternalInterface.call("webSocketLog", encodeURIComponent("[WebSocket] " + message)); + } } public function error(message:String):void { diff --git a/include/web-socket-js/web_socket.js b/include/web-socket-js/web_socket.js index 07ff7b53..2d3317c3 100755 --- a/include/web-socket-js/web_socket.js +++ b/include/web-socket-js/web_socket.js @@ -255,7 +255,7 @@ WebSocket.__tasks = []; - WebSocket.__initialize = function() { + WebSocket.__initialize = function(debug) { if (!WebSocket.__swfLocation) { console.error("[WebSocket] set WebSocket.__swfLocation to location of WebSocketMain.swf"); return; @@ -283,6 +283,9 @@ //console.log("[WebSocket] FABridge initializad"); WebSocket.__flash = FABridge.webSocket.root(); WebSocket.__flash.setCallerUrl(location.href); + if (typeof debug !== "undefined") { + WebSocket.__flash.setDebug(debug); + } for (var i = 0; i < WebSocket.__tasks.length; ++i) { WebSocket.__tasks[i](); }