Implemented packet deconstruction
This commit is contained in:
parent
4fe5dbb73a
commit
7ad297526c
@ -41,4 +41,30 @@ public class ProtocolMessage {
|
||||
|
||||
composeRawData(length, message);
|
||||
}
|
||||
|
||||
public ProtocolMessage(char[] raw) {
|
||||
this.raw = raw;
|
||||
|
||||
deconstructPacket(raw);
|
||||
}
|
||||
|
||||
private void deconstructPacket(char[] raw){
|
||||
byte[] rawLength = new byte[4];
|
||||
System.arraycopy(raw, 0, rawLength, 0, 4);
|
||||
System.arraycopy(raw, 4, this.message, 0, message.length);
|
||||
|
||||
this.length = byteToInt(rawLength);
|
||||
}
|
||||
|
||||
public int getLength() {
|
||||
return length;
|
||||
}
|
||||
|
||||
public char[] getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public char[] getRaw() {
|
||||
return raw;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user