mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-07 00:28:46 +00:00
Issue #707 Debugger for logging messages
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
package com.jpexs.decompiler.flash.debugger {
|
||||
|
||||
import flash.net.Socket;
|
||||
import flash.utils.ByteArray;
|
||||
import flash.events.Event;
|
||||
import flash.display.Sprite;
|
||||
|
||||
public class DebugConnection {
|
||||
|
||||
private static var s:Socket;
|
||||
private static var q = [];
|
||||
private static var first:Boolean = true;
|
||||
private static var inited:Boolean = false;
|
||||
private static var name:String;
|
||||
|
||||
|
||||
|
||||
private static function sendQueue(){
|
||||
var qo = q;
|
||||
q = [];
|
||||
for each(var m in qo){
|
||||
writeMsg(m);
|
||||
}
|
||||
}
|
||||
|
||||
private static function writeString(msg){
|
||||
var b:ByteArray = new ByteArray();
|
||||
b.writeUTFBytes(msg);
|
||||
s.writeByte(b.length);
|
||||
s.writeBytes(b,0,b.length);
|
||||
}
|
||||
|
||||
public static function initClient(sname){
|
||||
if(inited){
|
||||
return;
|
||||
}
|
||||
name = sname;
|
||||
inited = true;
|
||||
s = new Socket();
|
||||
s.addEventListener(Event.CONNECT, function(){
|
||||
sendQueue();
|
||||
});
|
||||
var port:int = 0;
|
||||
port = 123456;
|
||||
s.connect("localhost",port);
|
||||
inited = true;
|
||||
}
|
||||
|
||||
public static function writeMsg(msg){
|
||||
if(!inited){
|
||||
initClient("");
|
||||
}
|
||||
if(s.connected){
|
||||
if(first){
|
||||
s.writeByte(0);
|
||||
writeString(name);
|
||||
first = false;
|
||||
}
|
||||
writeString(msg);
|
||||
}else{
|
||||
q.push(msg);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.jpexs.decompiler.flash.debugger {
|
||||
|
||||
import flash.display.MovieClip;
|
||||
|
||||
|
||||
public class DebugMain extends MovieClip {
|
||||
|
||||
|
||||
public function DebugMain() {
|
||||
debugAlert("test alert");
|
||||
debugConsole("test console");
|
||||
debugSocket("test proxy");
|
||||
debugTrace("test trace");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.jpexs.decompiler.flash.debugger {
|
||||
|
||||
import flash.external.ExternalInterface;
|
||||
|
||||
public function debugAlert(msg):*{
|
||||
if(ExternalInterface.available)
|
||||
ExternalInterface.call("alert",""+msg);
|
||||
return msg;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.jpexs.decompiler.flash.debugger {
|
||||
|
||||
import flash.external.ExternalInterface;
|
||||
|
||||
public function debugConsole(msg):*{
|
||||
if(ExternalInterface.available)
|
||||
ExternalInterface.call("console.log",""+msg);
|
||||
return msg;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.jpexs.decompiler.flash.debugger {
|
||||
|
||||
|
||||
public function debugInit(name){
|
||||
DebugConnection.iniClient(name);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.jpexs.decompiler.flash.debugger {
|
||||
import flash.system.Capabilities;
|
||||
|
||||
public function debugSocket(msg):*{
|
||||
//only on webpages or activex
|
||||
if(Capabilities.playerType == 'PlugIn'
|
||||
|| Capabilities.playerType == 'ActiveX'){
|
||||
DebugConnection.writeMsg(msg);
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.jpexs.decompiler.flash.debugger {
|
||||
|
||||
|
||||
public function debugTrace(name){
|
||||
debugConsole(name);
|
||||
debugSocket(name);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user