|
@@ -1,5 +1,6 @@
|
|
|
package at.acdp.urweb.sclient;
|
|
|
|
|
|
+import at.acdp.urweb.sclient.data.MessageType;
|
|
|
import at.acdp.urweb.sclient.data.VersionMessage;
|
|
|
|
|
|
import java.io.*;
|
|
@@ -27,29 +28,36 @@ public class SecondaryClient {
|
|
|
VersionMessage vm = new VersionMessage();
|
|
|
vm.readVersionMessage(in);
|
|
|
System.out.println(vm);
|
|
|
- readReply(in);
|
|
|
+ while(in.available()>0) {
|
|
|
+ readReply(in);
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void readReply(DataInputStream di) throws IOException {
|
|
|
- int size=di.readInt();
|
|
|
- int mType= di.readByte() &0xff;
|
|
|
+ byte[] asdf=new byte[150];
|
|
|
+ //di.readFully(asdf);
|
|
|
+ System.out.println(asdf);
|
|
|
+
|
|
|
+ int size=di.readInt(); //4
|
|
|
+ int mType= di.readByte() &0xff; //+1=5
|
|
|
switch (mType) {
|
|
|
- case 20:
|
|
|
- long ts=di.readLong();
|
|
|
- byte source=di.readByte();
|
|
|
- int robotMessageType=di.readByte() & 0xff;
|
|
|
+ case MessageType.ROBOT_MESSAGE:
|
|
|
+ long ts=di.readLong();//+8=11
|
|
|
+ byte source=di.readByte(); //+1=12
|
|
|
+ int robotMessageType=di.readByte() & 0xff; //+1=13
|
|
|
switch(robotMessageType) {
|
|
|
+
|
|
|
default:
|
|
|
System.out.println("rtype: " +robotMessageType);
|
|
|
int x=di.available();
|
|
|
- byte[] buf=new byte[size-15];
|
|
|
- di.read(buf);
|
|
|
+ byte[] buf=new byte[size-10];
|
|
|
+ di.readFully(buf);
|
|
|
System.out.println(buf);
|
|
|
}
|
|
|
break;
|
|
|
case 16:
|
|
|
System.out.println("16 msg" + mType);
|
|
|
-
|
|
|
int remaining=size-5;
|
|
|
while (remaining >0) {
|
|
|
int sublength = in.readInt();
|
|
@@ -63,8 +71,8 @@ public class SecondaryClient {
|
|
|
break;
|
|
|
default:
|
|
|
System.out.println("unknown msg" + mType);
|
|
|
- byte[] buf=new byte[size];
|
|
|
- di.read(buf);
|
|
|
+ byte[] buf=new byte[size-5];
|
|
|
+ di.readFully(buf);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -73,7 +81,6 @@ public class SecondaryClient {
|
|
|
System.out.println("send cmd:" + cmd);
|
|
|
os.write(cmd.getBytes(StandardCharsets.UTF_8));
|
|
|
readReply(in);
|
|
|
-
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|