naga
public interface PacketReader
To implement a packet reader, the reader has to offer the currently
used byte buffer whenever the NIO service calls PacketReader#getBuffer()
PacketReader#getNextPacket()
should return a byte-array if it is possible to create
one from the data loaded into the buffer(s).
Note that getNextPacket() will be called repeatedly until it returns null.
Modifier and Type | Method and Description |
---|---|
java.nio.ByteBuffer |
getBuffer()
Return the currently used byte buffer.
|
byte[] |
getNextPacket()
Return the next packet constructed from the data read in the buffers.
|
java.nio.ByteBuffer getBuffer() throws ProtocolViolationException
The reader is guaranteed not to have this method called more than once before a
call to PacketReader#getNextPacket()
is made.
ProtocolViolationException
- if a protocol violation was detected when
reading preparing the buffer.byte[] getNextPacket() throws ProtocolViolationException
This call may or may not have been proceeded by a call to getBuffer().
The calling thread will call this method repeatedly until it returns null.
ProtocolViolationException
- if a protocol violation was detected when
parsing the next packet.