net.i2p.data.i2cp

## Class MessageStatusMessage

- java.lang.Object
- - net.i2p.data.i2cp.I2CPMessageImpl
  - - net.i2p.data.i2cp.MessageStatusMessage

- All Implemented Interfaces:
    I2CPMessage

      public class MessageStatusMessage
      extends I2CPMessageImpl

  Defines the message a router sends to a client about a single message. For incoming messages, it tells the client that a new message is available. For outgoing messages, it tells the client whether the message was delivered.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `MESSAGE_TYPE`
    `static int` | `STATUS_AVAILABLE` For incoming messages.
    `static int` | `STATUS_SEND_ACCEPTED`
    `static int` | `STATUS_SEND_BEST_EFFORT_FAILURE` A probable failure, but we don't know for sure.
    `static int` | `STATUS_SEND_BEST_EFFORT_SUCCESS` unused
    `static int` | `STATUS_SEND_FAILURE_BAD_LEASESET` We got the far-end leaseset but something strange is wrong with it.
    `static int` | `STATUS_SEND_FAILURE_BAD_MESSAGE` The message payload is invalid or zero-length or too big.
    `static int` | `STATUS_SEND_FAILURE_BAD_OPTIONS` Something is invalid in the message options, or the expiration is too far in the future.
    `static int` | `STATUS_SEND_FAILURE_BAD_SESSION` The session is invalid or closed.
    `static int` | `STATUS_SEND_FAILURE_DESTINATION` Something strange is wrong with the far-end destination.
    `static int` | `STATUS_SEND_FAILURE_EXPIRED` Message expired before it could be sent.
    `static int` | `STATUS_SEND_FAILURE_EXPIRED_LEASESET` We got the far-end leaseset but it's expired and can't get a new one.
    `static int` | `STATUS_SEND_FAILURE_LOCAL` The far-end destination is local but delivery failed for some reason.
    `static int` | `STATUS_SEND_FAILURE_LOCAL_LEASESET` Local leaseset problems.
    `static int` | `STATUS_SEND_FAILURE_LOOPBACK` Message was attempted to be sent to the same Destination.
    `static int` | `STATUS_SEND_FAILURE_META_LEASESET` The far-end destination's lease set was a meta lease set, and cannot be sent to.
    `static int` | `STATUS_SEND_FAILURE_NETWORK` The PC apparently has no network connectivity at all.
    `static int` | `STATUS_SEND_FAILURE_NO_LEASESET` Could not find the far-end destination's lease set.
    `static int` | `STATUS_SEND_FAILURE_NO_TUNNELS` Local problems - no outbound tunnel to send through, or no inbound tunnel if a reply is required.
    `static int` | `STATUS_SEND_FAILURE_OVERFLOW` Some queue or buffer in the router is full and the message was dropped.
    `static int` | `STATUS_SEND_FAILURE_ROUTER` The router is not ready, has shut down, or has major problems.
    `static int` | `STATUS_SEND_FAILURE_UNSUPPORTED_ENCRYPTION` The certs or options in the destination or leaseset indicate that it uses an encryption format that we don't support, so we can't talk to it.
    `static int` | `STATUS_SEND_GUARANTEED_FAILURE` Generic failure, specific cause unknown.
    `static int` | `STATUS_SEND_GUARANTEED_SUCCESS` Generic success.
    `static int` | `STATUS_SEND_SUCCESS_LOCAL` The far-end destination is local and we are pretty darn sure the delivery succeeded.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `MessageStatusMessage()` NOTE: Add any new status codes to handlers in: net.i2p.client.impl.MessageState net.i2p.client.impl.MessageStatusMessageHandler net.i2p.client.streaming.I2PSocketException net.i2p.client.streaming.impl.PacketQueue net.i2p.i2ptunnel.I2PTunnelHTTPClientBase and update http://i2p-projekt.i2p/spec/i2cp

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `doReadMessage(InputStream in, int size)` Read in the payload part of the message (after the initial 4 byte size and 1 byte type)
    `protected byte[]` | `doWriteMessage()` Write out the payload part of the message (not including the 4 byte size and 1 byte type)
    `long` | `getMessageId()` This is the router's ID for the message
    `long` | `getNonce()` This is the client's ID for the message
    `long` | `getSessionId()`
    `long` | `getSize()`
    `int` | `getStatus()`
    `static String` | `getStatusString(int status)`
    `int` | `getType()` Return the unique identifier for this type of message, as specified in the network specification document under #ClientAccessLayerMessages
    `boolean` | `isSuccessful()` Is the status code a success status code?
    `static boolean` | `isSuccessful(int status)` Is the status code a success status code?
    `SessionId` | `sessionId()` Return the SessionId for this message.
    `void` | `setMessageId(long id)` This is the router's ID for the message
    `void` | `setNonce(long nonce)` This is the client's ID for the message
    `void` | `setSessionId(long id)` Sets the session ID.
    `void` | `setSize(long size)`
    `void` | `setStatus(int status)` Sets the status code.
    `String` | `toString()`
    `void` | `writeMessage(OutputStream out)` Override to reduce mem churn

    - ### Methods inherited from class net.i2p.data.i2cp.I2CPMessageImpl

      `readBytes, readMessage, readMessage, writeBytes`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### MESSAGE_TYPE

          public static final int MESSAGE_TYPE

      See Also:
        Constant Field Values

    - #### STATUS_AVAILABLE

          public static final int STATUS_AVAILABLE

      For incoming messages. All the rest are for outgoing.
      See Also:
        Constant Field Values

    - #### STATUS_SEND_ACCEPTED

          public static final int STATUS_SEND_ACCEPTED

      See Also:
        Constant Field Values

    - #### STATUS_SEND_BEST_EFFORT_FAILURE

          public static final int STATUS_SEND_BEST_EFFORT_FAILURE

      A probable failure, but we don't know for sure.
      See Also:
        Constant Field Values

    - #### STATUS_SEND_BEST_EFFORT_SUCCESS

          public static final int STATUS_SEND_BEST_EFFORT_SUCCESS

      unused
      See Also:
        Constant Field Values

    - #### STATUS_SEND_FAILURE_BAD_LEASESET

          public static final int STATUS_SEND_FAILURE_BAD_LEASESET

      We got the far-end leaseset but something strange is wrong with it. Unsupported options or certificates, no tunnels, etc. This is a guaranteed failure.
      See Also:
        Constant Field Values

    - #### STATUS_SEND_FAILURE_BAD_MESSAGE

          public static final int STATUS_SEND_FAILURE_BAD_MESSAGE

      The message payload is invalid or zero-length or too big. This is a guaranteed failure.
      See Also:
        Constant Field Values

    - #### STATUS_SEND_FAILURE_BAD_OPTIONS

          public static final int STATUS_SEND_FAILURE_BAD_OPTIONS

      Something is invalid in the message options, or the expiration is too far in the future. This is a guaranteed failure.
      See Also:
        Constant Field Values

    - #### STATUS_SEND_FAILURE_BAD_SESSION

          public static final int STATUS_SEND_FAILURE_BAD_SESSION

      The session is invalid or closed. This is a guaranteed failure.
      See Also:
        Constant Field Values

    - #### STATUS_SEND_FAILURE_DESTINATION

          public static final int STATUS_SEND_FAILURE_DESTINATION

      Something strange is wrong with the far-end destination. Bad format, unsupported options, certificates, etc. This is a guaranteed failure.
      See Also:
        Constant Field Values

    - #### STATUS_SEND_FAILURE_EXPIRED

          public static final int STATUS_SEND_FAILURE_EXPIRED

      Message expired before it could be sent. This is a guaranteed failure.
      See Also:
        Constant Field Values

    - #### STATUS_SEND_FAILURE_EXPIRED_LEASESET

          public static final int STATUS_SEND_FAILURE_EXPIRED_LEASESET

      We got the far-end leaseset but it's expired and can't get a new one. This is a guaranteed failure.
      See Also:
        Constant Field Values

    - #### STATUS_SEND_FAILURE_LOCAL

          public static final int STATUS_SEND_FAILURE_LOCAL

      The far-end destination is local but delivery failed for some reason. This is a guaranteed failure.
      See Also:
        Constant Field Values

    - #### STATUS_SEND_FAILURE_LOCAL_LEASESET

          public static final int STATUS_SEND_FAILURE_LOCAL_LEASESET

      Local leaseset problems. The client has not yet signed a leaseset, or the local keys are invalid, or it has expired, or it does not have any tunnels in it. This is a guaranteed failure.
      See Also:
        Constant Field Values

    - #### STATUS_SEND_FAILURE_LOOPBACK

          public static final int STATUS_SEND_FAILURE_LOOPBACK

      Message was attempted to be sent to the same Destination. This is a guaranteed failure.
      See Also:
        Constant Field Values

    - #### STATUS_SEND_FAILURE_META_LEASESET

          public static final int STATUS_SEND_FAILURE_META_LEASESET

      The far-end destination's lease set was a meta lease set, and cannot be sent to. The client should request the meta lease set's contents with a HostLookupMessage, and select one of the hashes contained within to lookup and send to. This is a guaranteed failure.
      See Also:
        Constant Field Values

    - #### STATUS_SEND_FAILURE_NETWORK

          public static final int STATUS_SEND_FAILURE_NETWORK

      The PC apparently has no network connectivity at all. This is a guaranteed failure.
      See Also:
        Constant Field Values

    - #### STATUS_SEND_FAILURE_NO_LEASESET

          public static final int STATUS_SEND_FAILURE_NO_LEASESET

      Could not find the far-end destination's lease set. This is a common failure, equivalent to a DNS lookup fail. This is a guaranteed failure.
      See Also:
        Constant Field Values

    - #### STATUS_SEND_FAILURE_NO_TUNNELS

          public static final int STATUS_SEND_FAILURE_NO_TUNNELS

      Local problems - no outbound tunnel to send through, or no inbound tunnel if a reply is required. This is a guaranteed failure.
      See Also:
        Constant Field Values

    - #### STATUS_SEND_FAILURE_OVERFLOW

          public static final int STATUS_SEND_FAILURE_OVERFLOW

      Some queue or buffer in the router is full and the message was dropped. This is a guaranteed failure.
      See Also:
        Constant Field Values

    - #### STATUS_SEND_FAILURE_ROUTER

          public static final int STATUS_SEND_FAILURE_ROUTER

      The router is not ready, has shut down, or has major problems. This is a guaranteed failure.
      See Also:
        Constant Field Values

    - #### STATUS_SEND_FAILURE_UNSUPPORTED_ENCRYPTION

          public static final int STATUS_SEND_FAILURE_UNSUPPORTED_ENCRYPTION

      The certs or options in the destination or leaseset indicate that it uses an encryption format that we don't support, so we can't talk to it. This is a guaranteed failure.
      See Also:
        Constant Field Values

    - #### STATUS_SEND_GUARANTEED_FAILURE

          public static final int STATUS_SEND_GUARANTEED_FAILURE

      Generic failure, specific cause unknown. May not really be a guaranteed failure, as the best-effort failure code is unused.
      See Also:
        Constant Field Values

    - #### STATUS_SEND_GUARANTEED_SUCCESS

          public static final int STATUS_SEND_GUARANTEED_SUCCESS

      Generic success. May not really be guaranteed, as the best-effort success code is unused.
      See Also:
        Constant Field Values

    - #### STATUS_SEND_SUCCESS_LOCAL

          public static final int STATUS_SEND_SUCCESS_LOCAL

      The far-end destination is local and we are pretty darn sure the delivery succeeded.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### MessageStatusMessage

          public MessageStatusMessage()

      NOTE: Add any new status codes to handlers in: net.i2p.client.impl.MessageState net.i2p.client.impl.MessageStatusMessageHandler net.i2p.client.streaming.I2PSocketException net.i2p.client.streaming.impl.PacketQueue net.i2p.i2ptunnel.I2PTunnelHTTPClientBase and update http://i2p-projekt.i2p/spec/i2cp

  - ### Method Detail

    - #### doReadMessage

          protected void doReadMessage(InputStream in,
                                       int size)
                                throws I2CPMessageException,
                                       IOException

      Description copied from class: `I2CPMessageImpl`
      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` - InputStream
        `size` - payload size
      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

      Description copied from class: `I2CPMessageImpl`
      Write out the payload part of the message (not including the 4 byte size and 1 byte type)
      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

    - #### getMessageId

          public long getMessageId()

      This is the router's ID for the message

    - #### getNonce

          public long getNonce()

      This is the client's ID for the message

    - #### getSessionId

          public long getSessionId()

    - #### getSize

          public long getSize()

    - #### getStatus

          public int getStatus()

    - #### getStatusString

          public static final String getStatusString(int status)

    - #### getType

          public int getType()

      Description copied from interface: `I2CPMessage`
      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

    - #### isSuccessful

          public boolean isSuccessful()

      Is the status code a success status code?

    - #### isSuccessful

          public static boolean isSuccessful(int status)

      Is the status code a success status code?

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

    - #### setMessageId

          public void setMessageId(long id)

      This is the router's ID for the message

    - #### setNonce

          public void setNonce(long nonce)

      This is the client's ID for the message

    - #### setSessionId

          public void setSessionId(long id)

      Sets the session ID.
      Parameters:
        `id` - 0-65535

    - #### setSize

          public void setSize(long size)

    - #### setStatus

          public void setStatus(int status)

      Sets the status code.
      Parameters:
        `status` - 0-255

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### 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` - OutputStream
      Throws:
        `IOException`
        `I2CPMessageException` - if the current object doesn't have sufficient data to write a properly formatted message.