All Implemented Interfaces:
I2CPMessage

public class SendMessageExpiresMessageextends SendMessageMessage
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 Details

    • MESSAGE_TYPE

      public static final int MESSAGE_TYPE
      The I2CP message type number for an expiry-timed send request.
      See Also:
    • _daf

      private final DateAndFlags _daf
      When the message expires, together with its flags.
  • Constructor Details

    • SendMessageExpiresMessage

      public SendMessageExpiresMessage()
      For reading. Deprecated for writing, use 4-arg constructor.
    • SendMessageExpiresMessage

      public SendMessageExpiresMessage(SessionId sessID, Destination dest, Payload payload, long nonce)
      For writing.
      Parameters:
      sessID - the session the message is sent under
      dest - the destination the message is addressed to
      payload - the message payload to send
      nonce - 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 under
      dest - the destination the message is addressed to
      payload - the message payload to send
      nonce - the transaction nonce the reply must echo
      options - the DateAndFlags wrapping the expiration timestamp and the message flags
  • Method Details

    • getExpiration

      public Date getExpiration()
      The Date object is created here, it is not cached. Use getExpirationTime() 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 of getExpiration().getTime().
      Returns:
      the expiration time
    • setExpiration

      public void setExpiration(Date d)
      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:
      readMessage in interface I2CPMessage
      Overrides:
      readMessage in class SendMessageMessage
      Parameters:
      in - stream to read from
      length - number of bytes in the message payload
      type - type of message (should equal I2CPMessage.getType())
      Throws:
      IOException - if there's an error reading from the stream
      I2CPMessageException - if the stream doesn't contain a valid message that this class can read.
    • writeMessage

      public void writeMessage(OutputStream out) throws I2CPMessageException, IOException
      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:
      writeMessage in interface I2CPMessage
      Overrides:
      writeMessage in class SendMessageMessage
      Parameters:
      out - receives the length, type and payload, in that order
      Throws:
      IOException - if there's an error writing to the stream
      I2CPMessageException - 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:
      getType in interface I2CPMessage
      Overrides:
      getType in class SendMessageMessage
      Returns:
      the I2CP message type number 36 assigned to this message class
    • toString

      public String toString()
      Returns a string representation of this message.
      Overrides:
      toString in class SendMessageMessage