public class PacketDecoder extends Object
Modifier and Type | Class and Description |
---|---|
static class |
PacketDecoder.DecodedPacket
Represents a packet and the data used to construct it
|
Modifier | Constructor and Description |
---|---|
private |
PacketDecoder() |
Modifier and Type | Method and Description |
---|---|
static BasicPacket |
decode(ByteBuffer buffer)
Returns the package starting at the current position in the buffer
|
static PacketDecoder.DecodedPacket |
decodePacket(ByteBuffer buffer)
Gives the packet along with the bytes consumed to construct it.
|
static PacketDecoder.DecodedPacket |
extractPacket(ByteBuffer buffer)
Takes a buffer possibly containing a packet.
|
static boolean |
isPongPacket(ByteBuffer buffer)
Test whether the buffer contains (the start of) a pong packet.
|
static int |
packetLength(ByteBuffer buffer)
Note that it assumes that the position of the ByteBuffer is at the
start of a packet and that we have enough data to actually read
an integer out of the buffer.
|
static int |
sniffChannel(ByteBuffer buffer)
Sniff channel ID for query result packets
|
public static BasicPacket decode(ByteBuffer buffer)
IllegalArgumentException
- if an unknown package code is
encounteredBufferUnderflowException
- if the buffer contains too little
data to decode the pcode.public static PacketDecoder.DecodedPacket decodePacket(ByteBuffer buffer)
public static int sniffChannel(ByteBuffer buffer)
public static boolean isPongPacket(ByteBuffer buffer)
public static int packetLength(ByteBuffer buffer)
public static PacketDecoder.DecodedPacket extractPacket(ByteBuffer buffer) throws BufferTooSmallException
If we return a packet when we return:
If we return null
there were no more packets
there to decode and the following is true of the buffer
null
if there are no more complete
packets in the buffer at this time.BufferTooSmallException
Copyright © 2017. All rights reserved.