mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-07 21:05:05 +00:00
Fixed twolevel nested debugging
This commit is contained in:
@@ -11,7 +11,6 @@
|
||||
|
||||
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 var failed:Boolean = false;
|
||||
@@ -34,12 +33,16 @@
|
||||
public static const MSG_DUMP_BYTEARRAY = 3;
|
||||
public static const MSG_REQUEST_BYTEARRAY = 4;
|
||||
public static const MSG_LOADER_URL_INFO = 5;
|
||||
public static const MSG_LOADER_MODIFY_BYTES = 6;
|
||||
public static const MSG_LOADER_MODIFY_BYTES = 6;
|
||||
|
||||
private static var connected:Boolean = false;
|
||||
|
||||
public static const SHOW_TRACE = false;
|
||||
|
||||
private static function sendQueue(){
|
||||
if (SHOW_TRACE) trace("debugswf: client " + name + " sending queue");
|
||||
var qo = q;
|
||||
q = [];
|
||||
sendHeader();
|
||||
for each(var m in qo){
|
||||
writeMsg(m.data,m.type);
|
||||
}
|
||||
@@ -103,25 +106,30 @@
|
||||
if(inited){
|
||||
return;
|
||||
}
|
||||
if (SHOW_TRACE) trace("debugswf: initing client " + sname);
|
||||
name = sname;
|
||||
inited = true;
|
||||
try {
|
||||
s = new Socket();
|
||||
s = new Socket();
|
||||
s.addEventListener(Event.CONNECT, onSocketConnect);
|
||||
s.addEventListener(ProgressEvent.SOCKET_DATA, onSocketData);
|
||||
var port:int = 0;
|
||||
port = 123456;
|
||||
port = 123456;
|
||||
if (SHOW_TRACE) trace("debugswf: connecting client " + sname + " to localhost:" + port) ;
|
||||
s.connect("localhost",port);
|
||||
|
||||
inited = true;
|
||||
} catch (e:SecurityError) {
|
||||
trace("Debugger helper failed to connect to localhost");
|
||||
if (SHOW_TRACE) trace("Debugger helper failed to connect to localhost");
|
||||
failed = true;
|
||||
}
|
||||
}
|
||||
|
||||
private static function onSocketConnect(event:Event):void {
|
||||
sendQueue();
|
||||
if (SHOW_TRACE) trace("debugswf: client " + name + " connected");
|
||||
sendHeader();
|
||||
connected = true;
|
||||
sendQueue();
|
||||
}
|
||||
|
||||
|
||||
@@ -150,8 +158,10 @@
|
||||
} else {
|
||||
ba.position = pos;
|
||||
}
|
||||
if (SHOW_TRACE) trace("debugswf: client " + name + " received bytearray of " + ba.length + " bytes");
|
||||
var onComplete = fillByteArraysEvents.pop();
|
||||
if (onComplete != null) {
|
||||
if (SHOW_TRACE) trace("debugswf: client " + name + " calling onComplete");
|
||||
onComplete.call(onComplete);
|
||||
}
|
||||
}
|
||||
@@ -200,15 +210,11 @@
|
||||
}
|
||||
|
||||
private static function sendHeader() {
|
||||
if (!first) {
|
||||
return;
|
||||
}
|
||||
if (!s.connected) {
|
||||
return;
|
||||
}
|
||||
writeStringNull("debug.version.major="+DEBUG_VERSION_MAJOR+";debug.version.minor="+DEBUG_VERSION_MINOR);
|
||||
writeString(name);
|
||||
first = false;
|
||||
}
|
||||
|
||||
public static function writeMsg(msg,msgType=0){
|
||||
@@ -216,7 +222,9 @@
|
||||
return;
|
||||
}
|
||||
if(!inited) {
|
||||
initClient("");
|
||||
var max:int = 100000;
|
||||
var randomInt:int = Math.floor(Math.random() * (max + 1));
|
||||
initClient("rand" + randomInt);
|
||||
}
|
||||
if ((msg is ByteArray) && msgType == MSG_DUMP_BYTEARRAY) {
|
||||
var ba2:ByteArray = new ByteArray();
|
||||
@@ -224,9 +232,9 @@
|
||||
msg = ba2;
|
||||
}
|
||||
|
||||
if(s.connected){
|
||||
sendHeader();
|
||||
s.writeByte(msgType);
|
||||
if(connected) {
|
||||
if (SHOW_TRACE) trace("debugswf: client " + name +" sending msg " + msgType);
|
||||
s.writeByte(msgType);
|
||||
switch(msgType){
|
||||
case MSG_STRING:
|
||||
writeString(msg);
|
||||
@@ -242,6 +250,7 @@
|
||||
break;
|
||||
case MSG_REQUEST_BYTEARRAY:
|
||||
fillByteArrays.push(msg);
|
||||
fillByteArraysEvents.push(null);
|
||||
break;
|
||||
case MSG_LOADER_MODIFY_BYTES:
|
||||
writeString(msg["url"]);
|
||||
@@ -251,7 +260,9 @@
|
||||
break;
|
||||
}
|
||||
s.flush();
|
||||
if (SHOW_TRACE) trace("debugswf: client " + name +" msg " + msgType + " sent");
|
||||
}else{
|
||||
if (SHOW_TRACE) trace("debugswf: client " + name +" pushing msg " + msgType + " to queue");
|
||||
q.push({type:msgType,data:msg});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user