class FragmentedMessage extends Object
| Constructor and Description |
|---|
FragmentedMessage(I2PAppContext ctx,
long messageId)FragmentedMessage. |
| Modifier and Type | Method and Description |
|---|---|
void | failed()Releases the fragments, marking the message as failed. |
int | getCompleteSize()The size of the complete message, in bytes. |
SimpleTimer2.TimedEvent | getExpireEvent()Used in the fragment handler so we can cancel the expire event on success. |
int | getFragmentCount()The number of fragments received so far. |
long | getLifetime()How long has this fragmented message been alive? |
long | getMessageId()The unique ID of this fragmented message. |
boolean | getReleased()Whether this message has been released after completion. |
long | getReleasedAfter()The lifetime at which the fragments were released, or 0 if not yet released. |
Hash | getTargetRouter()The router this message is being sent to. |
TunnelId | getTargetTunnel()The tunnel this message is being sent to. |
boolean | isComplete()Have we received all of the fragments? |
boolean | receive(byte[] payload,
int offset,
int length,
boolean isLast,
Hash toRouter,
TunnelId toTunnel)Receive the first fragment (#0) and related metadata. |
boolean | receive(int fragmentNum,
byte[] payload,
int offset,
int length,
boolean isLast)Receive a followup fragment, though one of these may arrive at the endpoint
prior to the fragment # 0. |
void | setExpireEvent(SimpleTimer2.TimedEvent evt)The expire event to cancel when this message completes. |
byte[] | toByteArray()The complete reassembled message data, freeing the fragments. |
String | toString()Debug description of the message ID and the received fragments. |
public FragmentedMessage(I2PAppContext ctx, long messageId)
public void failed()
public int getCompleteSize()
public SimpleTimer2.TimedEvent getExpireEvent()
public int getFragmentCount()
public long getLifetime()
public long getMessageId()
public boolean getReleased()
public long getReleasedAfter()
public Hash getTargetRouter()
public TunnelId getTargetTunnel()
public boolean isComplete()
public boolean receive(byte[] payload,
int offset,
int length,
boolean isLast,
Hash toRouter,
TunnelId toTunnel)payload - data for the fragment non-nulloffset - index into the payload where the fragment data starts (past headers/etc)length - how much past the offset should we snag?isLast - is this the last fragment in the message?toRouter - what router is this destined for (may be null)toTunnel - what tunnel is this destined for (may be null)public boolean receive(int fragmentNum,
byte[] payload,
int offset,
int length,
boolean isLast)fragmentNum - sequence number within the message (1 - 63)payload - data for the fragment non-nulloffset - index into the payload where the fragment data starts (past headers/etc)length - how much past the offset should we snag?isLast - is this the last fragment in the message?public void setExpireEvent(SimpleTimer2.TimedEvent evt)
public byte[] toByteArray()