mirror of
https://github.com/sirjonasxx/G-Earth.git
synced 2024-11-23 08:50:52 +01:00
why much code if less do trick
This commit is contained in:
parent
7862828633
commit
750fff662f
@ -18,24 +18,15 @@ public class PayloadBuffer {
|
|||||||
}
|
}
|
||||||
public HPacket[] receive() {
|
public HPacket[] receive() {
|
||||||
if (buffer.length < 6) return new HPacket[0];
|
if (buffer.length < 6) return new HPacket[0];
|
||||||
|
|
||||||
HPacket total = new HPacket(buffer);
|
HPacket total = new HPacket(buffer);
|
||||||
if (total.getBytesLength() - 4 == total.length()) {
|
|
||||||
buffer = new byte[0];
|
ArrayList<HPacket> all = new ArrayList<>();
|
||||||
return new HPacket[]{total};
|
while (total.getBytesLength() >= 4 && total.getBytesLength() - 4 >= total.length()){
|
||||||
}
|
all.add(new HPacket(Arrays.copyOfRange(buffer, 0, total.length() + 4)));
|
||||||
else if (total.getBytesLength() - 4 > total.length()) {
|
buffer = Arrays.copyOfRange(buffer, total.length() + 4, buffer.length);
|
||||||
ArrayList<HPacket> all = new ArrayList<>();
|
total = new HPacket(buffer);
|
||||||
while (total.getBytesLength() >= 4 && total.getBytesLength() - 4 >= total.length()){
|
|
||||||
all.add(new HPacket(Arrays.copyOfRange(buffer, 0, total.length() + 4)));
|
|
||||||
buffer = Arrays.copyOfRange(buffer, total.length() + 4, buffer.length);
|
|
||||||
total = new HPacket(buffer);
|
|
||||||
}
|
|
||||||
return all.toArray(new HPacket[all.size()]);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return new HPacket[0];
|
|
||||||
}
|
}
|
||||||
|
return all.toArray(new HPacket[all.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user