public class Datagram
extends Object
Encodes/decodes data to/from big-endian byte order data format:
Name | Type | Size(byte) | Offset |
Status Flag | byte | 1 | 0 |
Sequence ID | long | 8 | 1 |
Data Type | byte | 1 | 9 |
Data Size | int | 4 | 10 |
Data Chunk | byte[] |
${Data Size} | 14 |
Modifier and Type | Field and Description |
---|---|
protected Object |
attachment |
protected CompletionHandler<Object> |
completionHandler |
protected EnumSet<CompletionHandler.CompletionType> |
completionTypes |
protected long |
expireTime |
protected long |
timeout |
Modifier and Type | Method and Description |
---|---|
protected static Datagram |
createACKResponseDatagram(long sequenceId) |
protected static Datagram |
createReceiveDatagram() |
static Datagram |
createRequestDatagram(byte type,
byte[] data) |
static Datagram |
createRequestDatagram(byte type,
ByteBuffer dataByteBuffer) |
static Datagram |
createResponseDatagram(Datagram requestDatagram,
byte[] data) |
static Datagram |
createResponseDatagram(Datagram requestDatagram,
ByteBuffer byteBuffer) |
ByteBuffer |
getDataByteBuffer() |
protected long |
getSequenceId() |
byte |
getType() |
protected boolean |
isAckRequest() |
protected boolean |
isAckResponse() |
protected boolean |
isRequest() |
protected boolean |
isResponse() |
protected boolean |
readFrom(ScatteringByteChannel scatteringByteChannel) |
protected void |
setAckRequest(boolean ackRequest) |
protected void |
setSequenceId(long sequenceId) |
String |
toString() |
protected boolean |
writeTo(GatheringByteChannel gatheringByteChannel) |
protected Object attachment
protected CompletionHandler<Object> completionHandler
protected EnumSet<CompletionHandler.CompletionType> completionTypes
protected long expireTime
protected long timeout
public static Datagram createRequestDatagram(byte type, byte[] data)
public static Datagram createRequestDatagram(byte type, ByteBuffer dataByteBuffer)
public static Datagram createResponseDatagram(Datagram requestDatagram, byte[] data)
public static Datagram createResponseDatagram(Datagram requestDatagram, ByteBuffer byteBuffer)
public ByteBuffer getDataByteBuffer()
public byte getType()
public String toString()
toString
in class Object
protected static Datagram createACKResponseDatagram(long sequenceId)
protected static Datagram createReceiveDatagram()
protected long getSequenceId()
protected boolean isAckRequest()
protected boolean isAckResponse()
protected boolean isRequest()
protected boolean isResponse()
protected boolean readFrom(ScatteringByteChannel scatteringByteChannel) throws IOException
IOException
protected void setAckRequest(boolean ackRequest)
protected void setSequenceId(long sequenceId)
protected boolean writeTo(GatheringByteChannel gatheringByteChannel) throws IOException
IOException