|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnaga.packetreader.RegularPacketReader
public class RegularPacketReader
Reads packet of the format
[header 1-4 bytes] => content size
[content] => 0-255/0-65535/0-16777215/0-2147483646
Note that the maximum size for 4 bytes is a signed 32 bit int, not unsigned.
Constructor Summary | |
---|---|
RegularPacketReader(int headerSize,
boolean bigEndian)
Creates a regular packet reader with the given header size. |
Method Summary | |
---|---|
java.nio.ByteBuffer |
getBuffer()
Return the next buffer to use. |
byte[] |
getNextPacket()
Return the next packet or null if no complete packet can be constructed. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public RegularPacketReader(int headerSize, boolean bigEndian)
headerSize
- the header size, 1 - 4 bytes.bigEndian
- big endian (largest byte first) or little endian (smallest byte first)Method Detail |
---|
public java.nio.ByteBuffer getBuffer() throws ProtocolViolationException
getBuffer
in interface PacketReader
ProtocolViolationException
- if the header was read and the size of the content is
larger or equal to Integer.MAX_VALUE.public byte[] getNextPacket() throws ProtocolViolationException
getNextPacket
in interface PacketReader
ProtocolViolationException
- if the size of the packet is larger or equal to Integer.MAX_VALUE.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |