public boolean readFromPacket(Packet packet) throws IOException {
Packet dup = packet.duplicate();
if( dup.remaining() < RECORD_HEADER_SIZE )
return false;
DataInputStream is = new DataInputStream(new PacketInputStream(dup));
readHeader( is );
if( dup.remaining() < payloadLength+RECORD_FOOTER_SIZE ) {
return false;
}
// Set limit to create a slice of the payload.
dup.limit(dup.position()+payloadLength);
this.payload = dup.slice();
if( isChecksumingEnabled() ) {
checksum(new DataInputStream(new PacketInputStream(payload)));
}
// restore the limit and seek to the footer.
dup.limit(packet.limit());
dup.position(dup.position()+payloadLength);