net.i2p.data.i2cp

## Interface I2CPMessage

- All Known Implementing Classes:
    BandwidthLimitsMessage, BlindingInfoMessage, CreateLeaseSet2Message, CreateLeaseSetMessage, CreateSessionMessage, DestLookupMessage, DestReplyMessage, DestroySessionMessage, DisconnectMessage, GetBandwidthLimitsMessage, GetDateMessage, HostLookupMessage, HostReplyMessage, I2CPMessageImpl, MessagePayloadMessage, MessageStatusMessage, PoisonI2CPMessage, ReceiveMessageBeginMessage, ReceiveMessageEndMessage, ReconfigureSessionMessage, ReportAbuseMessage, RequestLeaseSetMessage, RequestVariableLeaseSetMessage, SendMessageExpiresMessage, SendMessageMessage, SessionStatusMessage, SetDateMessage

      public interface I2CPMessage

  Defines the base functionality of API messages As of 0.9.48, does NOT extend DataStructure.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `getType()` Return the unique identifier for this type of message, as specified in the network specification document under #ClientAccessLayerMessages
    `void` | `readMessage(InputStream in)` Read the contents from the input stream into the current class's format.
    `void` | `readMessage(InputStream in, int size, int type)` Read the contents from the input stream into the current class's format.
    `SessionId` | `sessionId()` Return the SessionId for this type of message.
    `void` | `writeMessage(OutputStream out)` Write the current message to the output stream as a full message following the specification from the I2CP definition.

- - ### Method Detail

    - #### getType

          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

    - #### readMessage

          void readMessage(InputStream in)
                    throws I2CPMessageException,
                           IOException

      Read the contents from the input stream into the current class's format. The stream should be the message header and body as defined by the I2CP specification
      Parameters:
        `in` - stream to read from
      Throws:
        `I2CPMessageException` - if the stream doesn't contain a valid message that this class can read.
        `IOException` - if there is a problem reading from the stream

    - #### readMessage

          void readMessage(InputStream in,
                           int size,
                           int type)
                    throws I2CPMessageException,
                           IOException

      Read the contents from the input stream into the current class's format. The stream should be the message body as defined by the client access layer specification after the message header (4 bytes specifying the size of the message, 1 byte specifying the type of the message).
      Parameters:
        `in` - stream to read from
        `size` - number of bytes in the message payload
        `type` - type of message (should equal getType())
      Throws:
        `I2CPMessageException` - if the stream doesn't contain a valid message that this class can read.
        `IOException` - if there is a problem reading from the stream

    - #### sessionId

          SessionId sessionId()

      Return the SessionId for this type of message. Most but not all message types include a SessionId. The ones that do already define getSessionId(), but some return a SessionId and some return a long, so we define a new method here.
      Returns:
        SessionId or null if this message type does not include a SessionId

    - #### writeMessage

          void writeMessage(OutputStream out)
                     throws I2CPMessageException,
                            IOException

      Write the current message to the output stream as a full message following the specification from the I2CP definition.
      Parameters:
        `out` - OutputStream
      Throws:
        `I2CPMessageException` - if the current object doesn't have sufficient data to write a properly formatted message.
        `IOException` - if there is a problem writing to the stream