if (!(message instanceof LSPacket)) {
Logger.error(new Exception("Wrong packet type! "
+ message.toString()));
return;
}
LSPacket p = (LSPacket) message;
byte[] data = p.getData();
int packetLength = data.length;
ByteBuffer buffer;
if (!p.isBare()) {
buffer = ByteBuffer.allocate(data.length + 13);
packetLength += 9;
buffer.putInt(packetLength);
buffer.put((byte) p.getID());
buffer.putLong(p.getUID());
} else {
buffer = ByteBuffer.allocate(data.length);
}
buffer.put(data, 0, data.length);