naga.packetreader
public class RawPacketReader extends java.lang.Object implements PacketReader
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_BUFFER_SIZE |
Constructor and Description |
---|
RawPacketReader()
Create a new reader instance with the default buffer size.
|
RawPacketReader(int bufferSize)
Create a new reader instance.
|
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.
|
public static final int DEFAULT_BUFFER_SIZE
public RawPacketReader(int bufferSize)
bufferSize
- the buffer size to use.public RawPacketReader()
public java.nio.ByteBuffer getBuffer()
PacketReader
The reader is guaranteed not to have this method called more than once before a
call to PacketReader#getNextPacket()
is made.
getBuffer
in interface PacketReader
public byte[] getNextPacket() throws ProtocolViolationException
PacketReader
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.
getNextPacket
in interface PacketReader
ProtocolViolationException
- if a protocol violation was detected when
parsing the next packet.