## net.i2p.data.i2cp
Interface I2CPMessage

All Superinterfaces:
  DataStructure

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

    public interface I2CPMessage

extends DataStructure

Defines the base functionality of API messages

Author:
  jrandom

Method Summary
`int` `getType()` Return the unique identifier for this type of APIMessage, 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.
`void` `writeMessage(OutputStream out)` Write the current message to the output stream as a full message following the specification from the I2CP definition.

Methods inherited from interface net.i2p.data.DataStructure
`calculateHash, fromBase64, fromByteArray, readBytes, toBase64, toByteArray, writeBytes`

Method Detail

### 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

### 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

### 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

### getType

    int getType()

  Return the unique identifier for this type of APIMessage, as specified in the network specification document under #ClientAccessLayerMessages

  Returns:
    unique identifier for this type of APIMessage