java.lang.Object
net.i2p.data.i2cp.I2CPMessageImpl
net.i2p.data.i2cp.SendMessageMessage
net.i2p.data.i2cp.SendMessageExpiresMessage
- All Implemented Interfaces:
I2CPMessage
Same as SendMessageMessage, but with an expiration to be passed to the router
As of 0.8.4, retrofitted to use DateAndFlags. Backwards compatible.
Field Summary
Modifier and TypeFieldDescriptionprivate final DateAndFlagsWhen the message expires, together with its flags.static final intThe I2CP message type number for an expiry-timed send request.Fields inherited from class SendMessageMessage
_destination, _nonce, _payload, _sessionIdModifier and TypeFieldDescriptionprotected DestinationDestination the payload is addressed to.protected longClient replay nonce, echoed back in the RejectMessage.protected PayloadData to deliver to that destination.protected SessionIdSession the payload is being sent over.Constructor Summary
ConstructorsConstructorDescriptionFor reading.SendMessageExpiresMessage(SessionId sessID, Destination dest, Payload payload, long nonce) For writing.SendMessageExpiresMessage(SessionId sessID, Destination dest, Payload payload, long nonce, DateAndFlags options) For writing.Method Summary
All MethodsModifier and TypeMethodDescriptionThe Date object is created here, it is not cached.longUse this instead ofgetExpiration().getTime().intgetFlags()Message flags.intgetType()Returns the I2CP message type number for this message.voidreadMessage(InputStream in, int length, int type) Read the body into the data structures.voidsetExpiration(long d) Message expiration time in ms.voidExpiration time of the message.voidsetFlags(int f) Message flags.toString()Returns a string representation of this message.voidwriteMessage(OutputStream out) Write out the full message to the stream, including the 4 byte size and 1 byte type header.Methods inherited from class SendMessageMessage
doReadMessage, doWriteMessage, getDestination, getNonce, getPayload, getSessionId, sessionIdModifier and TypeMethodDescriptionprotected voiddoReadMessage(InputStream in, int size) Read in the payload part of the message (after the initial 4 byte size and 1 byte type).protected byte[]Serialization is not supported for this message.Destination the message is being sent to.longgetNonce()Message nonce.Message payload being sent.Session ID the message is being sent to.Return the SessionId for this message.Methods inherited from class I2CPMessageImpl
readBytes, readMessage, writeBytesModifier and TypeMethodDescriptionvoidreadBytes(InputStream in) Read the message from the stream, wrapping I2CPMessageException inDataFormatException.voidValidate the type and size of the message, and then read the message into the data structures.voidwriteBytes(OutputStream out) Write the message to the stream, wrapping I2CPMessageException in DataFormatException.
Field Details
MESSAGE_TYPE
public static final int MESSAGE_TYPEThe I2CP message type number for an expiry-timed send request.- See Also:
_daf
When the message expires, together with its flags.
Constructor Details
SendMessageExpiresMessage
public SendMessageExpiresMessage()For reading. Deprecated for writing, use 4-arg constructor.SendMessageExpiresMessage
For writing.- Parameters:
sessID- the session the message is sent underdest- the destination the message is addressed topayload- the message payload to sendnonce- the transaction nonce the reply must echo
SendMessageExpiresMessage
public SendMessageExpiresMessage(SessionId sessID, Destination dest, Payload payload, long nonce, DateAndFlags options) For writing.- Parameters:
sessID- the session the message is sent underdest- the destination the message is addressed topayload- the message payload to sendnonce- the transaction nonce the reply must echooptions- the DateAndFlags wrapping the expiration timestamp and the message flags
Method Details
getExpiration
The Date object is created here, it is not cached. UsegetExpirationTime()if you only need the long value.- Returns:
- the absolute date after which the message should be discarded, built fresh from the wire timestamp on every call and never null
getExpirationTime
public long getExpirationTime()Use this instead ofgetExpiration().getTime().- Returns:
- the expiration time
setExpiration
Expiration time of the message.- Parameters:
d- the absolute expiration date, replacing any previously set one
setExpiration
public void setExpiration(long d) Message expiration time in ms.- Parameters:
d- milliseconds since the epoch, replacing any previously set expiration
getFlags
public int getFlags()Message flags.- Returns:
- the application-specific flag bitmask from the trailing two wire bytes, in the range 0 to 65535
setFlags
public void setFlags(int f) Message flags.- Parameters:
f- the flag bitmask to store, replacing any previously set flags
readMessage
public void readMessage(InputStream in, int length, int type) throws I2CPMessageException, IOException Read the body into the data structures.- Specified by:
readMessagein interfaceI2CPMessage- Overrides:
readMessagein classSendMessageMessage- Parameters:
in- stream to read fromlength- number of bytes in the message payloadtype- type of message (should equalI2CPMessage.getType())- Throws:
IOException- if there's an error reading from the streamI2CPMessageException- if the stream doesn't contain a valid message that this class can read.
writeMessage
Write out the full message to the stream, including the 4 byte size and 1 byte type header. Override the parent so we can be more mem efficient.- Specified by:
writeMessagein interfaceI2CPMessage- Overrides:
writeMessagein classSendMessageMessage- Parameters:
out- receives the length, type and payload, in that order- Throws:
IOException- if there's an error writing to the streamI2CPMessageException- if the current object doesn't have sufficient data to write a properly formatted message.
getType
public int getType()Returns the I2CP message type number for this message.- Specified by:
getTypein interfaceI2CPMessage- Overrides:
getTypein classSendMessageMessage- Returns:
- the I2CP message type number 36 assigned to this message class
toString
Returns a string representation of this message.- Overrides:
toStringin classSendMessageMessage