public abstract class AbstractApplicationPacket extends AbstractPacket implements ApplicationPacket
| Constructor and Description |
|---|
AbstractApplicationPacket(Protocol p,
TransportPacket parent,
Buffer payload) |
| Modifier and Type | Method and Description |
|---|---|
abstract ApplicationPacket |
clone() |
long |
getArrivalTime()
The arrival time of this packet in microseconds relative to epoch
(midnight UTC of January 1, 1970).
|
protected TransportPacket |
getParent() |
void |
write(OutputStream out,
Buffer payload)
Writes this packet to the
OutputStream with the supplied payload. |
checkParent, getName, getPacket, getParentPacket, getPayload, getProtocol, hasProtocol, verify, writeequals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetName, getNextPacket, getPacket, getParentPacket, getPayload, getProtocol, hasProtocol, verify, writepublic AbstractApplicationPacket(Protocol p, TransportPacket parent, Buffer payload)
p - parent - payload - protected TransportPacket getParent()
public final long getArrivalTime()
SimpleDateFormat but it can
only handle milliseconds precision (you will have to write your own date
formatter if you want microseconds).
Here is a snippet illustrating how to turn the arrival time of the packet
into a human readable date
Packet p = ...;
SimpleDateFormat formatter = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss.SSS");
Date date = new Date(p.getArrivalTime() / 1000);
System.out.println("Arrival time: " + formatter.format(date));
Note how an integer devision is performed on the arrival time to
"cut off" the microseconds from the time stampgetArrivalTime in interface Packetpublic void write(OutputStream out, Buffer payload) throws IOException
OutputStream with the supplied payload.
You can use this method to e.g. write a raw UDPPacket to the
stream with this payload. Note, if the UDPPacket already had a
payload it will be ignored so use this method with care.write in interface PacketIOExceptionpublic abstract ApplicationPacket clone()
clone in interface Packetclone in class AbstractPacketCopyright © 2021. All Rights Reserved.