public class Packet extends Object
The contents is typically multiple messages (ACK,PING etc) or all or part of a RemoteTransactionEvent.
Due to the hard limit on the size of UDP packets a RemoteTransactionEvent with lots of information could be broken up into multiple packets.
| Modifier and Type | Field and Description |
|---|---|
protected ByteArrayOutputStream |
buffer |
protected byte[] |
bytes |
protected DataOutputStream |
dataOut |
protected long |
packetId
The PacketId.
|
protected short |
packetType
The type of Packet.
|
protected String |
serverName
The EbeanServer name this relates to if relevant.
|
protected long |
timestamp
The timestamp the Packet was created.
|
static short |
TYPE_MESSAGES
A Packet that holds protocol messages like ACK, PING etc.
|
static short |
TYPE_TRANSEVENT
A Packet that holds TransactionEvent information such as Bean
and or Table IUD information.
|
| Modifier | Constructor and Description |
|---|---|
protected |
Packet(boolean write,
short packetType,
long packetId,
long timestamp,
String serverName) |
| Modifier and Type | Method and Description |
|---|---|
static Packet |
forWrite(short packetType,
long packetId,
long timestamp,
String serverName)
Create a Packet for writing messages to.
|
byte[] |
getBytes()
Return the Packet as raw bytes.
|
long |
getPacketId() |
short |
getPacketType() |
String |
getServerName() |
int |
getSize() |
long |
getTimestamp() |
int |
incrementResendCount() |
void |
read(DataInput dataInput) |
static Packet |
readHeader(DataInput dataInput)
Create a Packet just reading the Header information.
|
protected void |
readMessage(DataInput dataInput,
int msgType)
Overridden by more specific Packet implementations to read the messages.
|
boolean |
writeBinaryMessage(BinaryMessage msg,
int maxPacketSize)
Write a binary message to this packet returning true if there was
enough room to do so.
|
void |
writeEof() |
public static final short TYPE_MESSAGES
public static final short TYPE_TRANSEVENT
protected short packetType
protected long packetId
protected long timestamp
protected String serverName
protected ByteArrayOutputStream buffer
protected DataOutputStream dataOut
protected byte[] bytes
protected Packet(boolean write,
short packetType,
long packetId,
long timestamp,
String serverName)
throws IOException
IOExceptionpublic static Packet forWrite(short packetType, long packetId, long timestamp, String serverName) throws IOException
IOExceptionpublic static Packet readHeader(DataInput dataInput) throws IOException
IOExceptionpublic int incrementResendCount()
public short getPacketType()
public long getPacketId()
public long getTimestamp()
public String getServerName()
public void writeEof()
throws IOException
IOExceptionpublic void read(DataInput dataInput) throws IOException
IOExceptionprotected void readMessage(DataInput dataInput, int msgType) throws IOException
IOExceptionpublic boolean writeBinaryMessage(BinaryMessage msg, int maxPacketSize) throws IOException
IOExceptionpublic int getSize()
public byte[] getBytes()
Copyright © 2014. All Rights Reserved.