use of cn.nukkit.raknet.protocol.EncapsulatedPacket in project Nukkit by Nukkit.
the class Session method handleSplit.
private void handleSplit(EncapsulatedPacket packet) throws Exception {
if (packet.splitCount >= MAX_SPLIT_SIZE || packet.splitIndex >= MAX_SPLIT_SIZE || packet.splitIndex < 0) {
return;
}
if (!this.splitPackets.containsKey(packet.splitID)) {
if (this.splitPackets.size() >= MAX_SPLIT_COUNT) {
return;
}
this.splitPackets.put(packet.splitID, new HashMap<Integer, EncapsulatedPacket>() {
{
put(packet.splitIndex, packet);
}
});
} else {
this.splitPackets.get(packet.splitID).put(packet.splitIndex, packet);
}
if (this.splitPackets.get(packet.splitID).size() == packet.splitCount) {
EncapsulatedPacket pk = new EncapsulatedPacket();
BinaryStream stream = new BinaryStream();
for (int i = 0; i < packet.splitCount; i++) {
stream.put(this.splitPackets.get(packet.splitID).get(i).buffer);
}
pk.buffer = stream.getBuffer();
pk.length = pk.buffer.length;
this.splitPackets.remove(packet.splitID);
this.handleEncapsulatedPacketRoute(pk);
}
}
Aggregations