mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-16 01:58:10 +00:00
socket debugger: 2bytes for string length
This commit is contained in:
@@ -26,7 +26,8 @@
|
||||
private static function writeString(msg){
|
||||
var b:ByteArray = new ByteArray();
|
||||
b.writeUTFBytes(msg);
|
||||
s.writeByte(b.length);
|
||||
s.writeByte((b.length>>8) & 0xff);
|
||||
s.writeByte(b.length & 0xff);
|
||||
s.writeBytes(b,0,b.length);
|
||||
}
|
||||
|
||||
|
||||
@@ -51,25 +51,31 @@ public class Debugger {
|
||||
}
|
||||
}
|
||||
|
||||
private String readString(InputStream is) throws IOException
|
||||
{
|
||||
private String readString(InputStream is) throws IOException {
|
||||
int len = is.read();
|
||||
if (len == -1) {
|
||||
throw new EOFException();
|
||||
}
|
||||
byte buf[] = new byte[len];
|
||||
for(int i=0;i<len;i++){
|
||||
int rd = is.read();
|
||||
if(rd == -1){
|
||||
throw new EOFException();
|
||||
}
|
||||
buf[i] = (byte)rd;
|
||||
}
|
||||
return new String(buf, "UTF-8");
|
||||
if (len == -1) {
|
||||
throw new EOFException();
|
||||
}
|
||||
int len2 = is.read();
|
||||
if (len2 == -1) {
|
||||
throw new EOFException();
|
||||
}
|
||||
len = (len << 8) + len2;
|
||||
|
||||
byte buf[] = new byte[len];
|
||||
for (int i = 0; i < len; i++) {
|
||||
int rd = is.read();
|
||||
if (rd == -1) {
|
||||
throw new EOFException();
|
||||
}
|
||||
buf[i] = (byte) rd;
|
||||
}
|
||||
return new String(buf, "UTF-8");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
String clientName = ""+id;
|
||||
String clientName = "" + id;
|
||||
try (InputStream is = s.getInputStream()) {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
|
||||
@@ -89,7 +95,7 @@ public class Debugger {
|
||||
}
|
||||
} else {
|
||||
String name = readString(is);
|
||||
if(!name.equals("")){
|
||||
if (!name.equals("")) {
|
||||
clientName = name;
|
||||
}
|
||||
while (true) {
|
||||
@@ -98,8 +104,8 @@ public class Debugger {
|
||||
l.onMessage(clientName, ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} catch (IOException ex) {
|
||||
//ignore
|
||||
}
|
||||
@@ -128,9 +134,9 @@ public class Debugger {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
ss = new ServerSocket(port,50,InetAddress.getByName("localhost"));
|
||||
ss.setReuseAddress(true);
|
||||
try {
|
||||
ss = new ServerSocket(port, 50, InetAddress.getByName("localhost"));
|
||||
ss.setReuseAddress(true);
|
||||
while (true) {
|
||||
Socket s = ss.accept();
|
||||
if (s != null) {
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user