java.lang.Object
net.i2p.data.i2cp.I2CPMessageImpl
net.i2p.data.i2cp.ReceiveMessageBeginMessage
All Implemented Interfaces:
I2CPMessage

public class ReceiveMessageBeginMessageextends I2CPMessageImpl
Defines the message a client sends to a router when asking the router to start sending a message to it.
  • Field Details

    • MESSAGE_TYPE

      public static final int MESSAGE_TYPE
      I2CP message type number identifying the start of an incoming message.
      See Also:
    • _sessionId

      private int _sessionId
      The session ID.
    • _messageId

      private long _messageId
      The message ID.
  • Constructor Details

    • ReceiveMessageBeginMessage

      public ReceiveMessageBeginMessage()
      Creates a message with an invalid session id.
  • Method Details

    • getSessionId

      public long getSessionId()
      Session identifier for this message.
      Returns:
      the session ID
    • 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.
    • setSessionId

      public void setSessionId(long id)
      Set the session the message is addressed to.
      Parameters:
      id - 0-65535
    • getMessageId

      public long getMessageId()
      Message identifier for delivery tracking.
      Returns:
      the message ID
    • setMessageId

      public void setMessageId(long id)
      Message identifier for delivery tracking.
      Parameters:
      id - the message ID
    • doReadMessage

      protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException
      Read the message body from the input stream.
      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
    • doWriteMessage

      protected byte[] doWriteMessage() throws I2CPMessageException, IOException
      Write the message body to the output stream.
      Specified by:
      doWriteMessage in class I2CPMessageImpl
      Returns:
      byte array
      Throws:
      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
      Override to reduce mem churn.
      Specified by:
      writeMessage in interface I2CPMessage
      Overrides:
      writeMessage in class I2CPMessageImpl
      Parameters:
      out - receives the length, type and payload, in that order
      Throws:
      IOException - on write error
      I2CPMessageException - if the current object doesn't have sufficient data to write a properly formatted message.
    • getType

      public int getType()
      Reports this message's I2CP type number.
      Returns:
      MESSAGE_TYPE, 6
    • toString

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