Commit 2ddd6214 authored by Joel Martin's avatar Joel Martin

Add web-socket-js debug flag and default to off.

parent 76053e2b
...@@ -21,6 +21,7 @@ public class WebSocketMain extends Sprite { ...@@ -21,6 +21,7 @@ public class WebSocketMain extends Sprite {
private var policyLoaded:Boolean = false; private var policyLoaded:Boolean = false;
private var callerUrl:String; private var callerUrl:String;
private var debug:Boolean = false;
public function WebSocketMain() { public function WebSocketMain() {
...@@ -42,6 +43,10 @@ public class WebSocketMain extends Sprite { ...@@ -42,6 +43,10 @@ public class WebSocketMain extends Sprite {
callerUrl = url; callerUrl = url;
} }
public function setDebug(val:Boolean):void {
debug = val;
}
public function create( public function create(
url:String, protocol:String, url:String, protocol:String,
proxyHost:String = null, proxyPort:int = 0, proxyHost:String = null, proxyPort:int = 0,
...@@ -70,8 +75,10 @@ public class WebSocketMain extends Sprite { ...@@ -70,8 +75,10 @@ public class WebSocketMain extends Sprite {
} }
public function log(message:String):void { public function log(message:String):void {
if (debug) {
ExternalInterface.call("webSocketLog", encodeURIComponent("[WebSocket] " + message)); ExternalInterface.call("webSocketLog", encodeURIComponent("[WebSocket] " + message));
} }
}
public function error(message:String):void { public function error(message:String):void {
ExternalInterface.call("webSocketError", encodeURIComponent("[WebSocket] " + message)); ExternalInterface.call("webSocketError", encodeURIComponent("[WebSocket] " + message));
......
...@@ -255,7 +255,7 @@ ...@@ -255,7 +255,7 @@
WebSocket.__tasks = []; WebSocket.__tasks = [];
WebSocket.__initialize = function() { WebSocket.__initialize = function(debug) {
if (!WebSocket.__swfLocation) { if (!WebSocket.__swfLocation) {
console.error("[WebSocket] set WebSocket.__swfLocation to location of WebSocketMain.swf"); console.error("[WebSocket] set WebSocket.__swfLocation to location of WebSocketMain.swf");
return; return;
...@@ -283,6 +283,9 @@ ...@@ -283,6 +283,9 @@
//console.log("[WebSocket] FABridge initializad"); //console.log("[WebSocket] FABridge initializad");
WebSocket.__flash = FABridge.webSocket.root(); WebSocket.__flash = FABridge.webSocket.root();
WebSocket.__flash.setCallerUrl(location.href); WebSocket.__flash.setCallerUrl(location.href);
if (typeof debug !== "undefined") {
WebSocket.__flash.setDebug(debug);
}
for (var i = 0; i < WebSocket.__tasks.length; ++i) { for (var i = 0; i < WebSocket.__tasks.length; ++i) {
WebSocket.__tasks[i](); WebSocket.__tasks[i]();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment