java.lang.Object
net.i2p.data.i2cp.I2CPMessageImpl
net.i2p.data.i2cp.SendMessageMessage
All Implemented Interfaces:
I2CPMessage
Direct Known Subclasses:
SendMessageExpiresMessage

public class SendMessageMessageextends I2CPMessageImpl
Defines the message a client sends to a router to ask it to deliver a new message.
  • Field Details

    • MESSAGE_TYPE

      public static final int MESSAGE_TYPE
      I2CP message type ID written to the wire header.
      See Also:
    • _sessionId

      protected SessionId _sessionId
      Session the payload is being sent over.
    • _destination

      protected Destination _destination
      Destination the payload is addressed to.
    • _payload

      protected Payload _payload
      Data to deliver to that destination.
    • _nonce

      protected long _nonce
      Client replay nonce, echoed back in the RejectMessage.
  • Constructor Details

    • SendMessageMessage

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

      public SendMessageMessage(SessionId sessID, Destination dest, Payload payload, long nonce)
      For writing.
      Parameters:
      sessID - the session the message is to be sent over
      dest - the destination to address the payload to
      payload - the data to deliver to that destination
      nonce - the client's replay nonce, echoed back in the RejectMessage
  • Method Details

    • getSessionId

      public SessionId getSessionId()
      Session ID the message is being sent to.
      Returns:
      the session this message belongs to
    • sessionId

      public SessionId sessionId()
      Return the SessionId for this message.
      Specified by:
      sessionId in interface I2CPMessage
      Overrides:
      sessionId in class I2CPMessageImpl
      Returns:
      null always. Extending classes with a SessionId must override.
    • getDestination

      public Destination getDestination()
      Destination the message is being sent to.
      Returns:
      the peer the message is addressed to, or null if unset
    • getPayload

      public Payload getPayload()
      Message payload being sent.
      Returns:
      the data to deliver to the destination, or null if unset
    • getNonce

      public long getNonce()
      Message nonce.
      Returns:
      0 to 0xffffffff
    • doReadMessage

      protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException
      Read in the payload part of the message (after the initial 4 byte size and 1 byte type).
      Specified by:
      doReadMessage in class I2CPMessageImpl
      Parameters:
      in - positioned just past the 4 byte size and 1 byte type header
      size - how many payload bytes remain to be read
      Throws:
      I2CPMessageException - if the message format is invalid
      IOException - if there's an error reading from the stream
    • 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 I2CPMessageImpl
      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.
    • doWriteMessage

      protected byte[] doWriteMessage() throws I2CPMessageException, IOException
      Serialization is not supported for this message.
      Specified by:
      doWriteMessage in class I2CPMessageImpl
      Returns:
      byte array
      Throws:
      UnsupportedOperationException - always; use writeMessage instead
      I2CPMessageException - if the message cannot be written
      IOException - if there's an error writing to the stream
    • 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 I2CPMessageImpl
      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()
      Return the unique identifier for this type of message, as specified in the network specification document under #ClientAccessLayerMessages.
      Returns:
      unique identifier for this type of message
    • toString

      public String toString()
      Overrides:
      toString in class Object