net.i2p.router

## Class OutNetMessage

- java.lang.Object
- - net.i2p.router.OutNetMessage

- All Implemented Interfaces:
    CDPQEntry, CDQEntry, PQEntry

      public class OutNetMessage
      extends Object
      implements CDPQEntry

  Wrap up an outbound I2NP message, along with the information associated with its delivery and jobs to be fired off if particular events occur.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `PRIORITY_BUILD_REPLY`
    `static int` | `PRIORITY_EXPLORATORY`
    `static int` | `PRIORITY_HIGHEST`
    `static int` | `PRIORITY_HIS_BUILD_REQUEST`
    `static int` | `PRIORITY_HIS_NETDB_STORE`
    `static int` | `PRIORITY_LOWEST` Priorities, higher is higher priority.
    `static int` | `PRIORITY_MEDIUM`
    `static int` | `PRIORITY_MY_BUILD_REQUEST`
    `static int` | `PRIORITY_MY_DATA`
    `static int` | `PRIORITY_MY_NETDB_LOOKUP`
    `static int` | `PRIORITY_MY_NETDB_STORE`
    `static int` | `PRIORITY_MY_NETDB_STORE_LOW`
    `static int` | `PRIORITY_NETDB_EXPLORE`
    `static int` | `PRIORITY_NETDB_FLOOD`
    `static int` | `PRIORITY_NETDB_HARVEST`
    `static int` | `PRIORITY_NETDB_REPLY`
    `static int` | `PRIORITY_PARTICIPATING`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `OutNetMessage(RouterContext context)` Null msg and target, zero expiration (used in OutboundMessageRegistry only)
    `OutNetMessage(RouterContext context, I2NPMessage msg, long expiration, int priority, RouterInfo target)` Standard constructor

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `beginSend()`
    `void` | `discardData()` We've done what we need to do with the data from this message, though we may keep the object around for a while to use its ID, jobs, etc.
    `void` | `drop()` For CDQ
    `long` | `getCreated()`
    `long` | `getEnqueueTime()` For CDQ
    `long` | `getExpiration()` Specify the # ms since the epoch after which if the message has not been sent the OnFailedSend job should be fired and the message should be removed from the pool.
    `int` | `getFailedTransportCount()`
    `List<String>` | `getFailedTransports()` As of 0.9.55, changed from a Set to a List
    `long` | `getLifetime()` time since the message was created
    `I2NPMessage` | `getMessage()` Specifies the message to be sent.
    `int` | `getMessageData(byte[] outBuffer)` Copies the message data to outbuffer.
    `long` | `getMessageId()`
    `int` | `getMessageSize()` How large the message is, including the full 16 byte header.
    `String` | `getMessageType()` For debugging only.
    `int` | `getMessageTypeId()`
    `Job` | `getOnFailedReplyJob()` If the Message selector is specified but it doesn't find a reply before its expiration passes, this job is enqueued.
    `Job` | `getOnFailedSendJob()` If the router could not be reached or the expiration passed, this job is enqueued.
    `ReplyJob` | `getOnReplyJob()` If the MessageSelector detects a reply, this job is enqueued
    `Job` | `getOnSendJob()` After the message is successfully passed to the router specified, the given job is enqueued.
    `int` | `getPriority()` Specify the priority of the message, where higher numbers are higher priority.
    `MessageSelector` | `getReplySelector()` Defines a MessageSelector to find a reply to this message.
    `long` | `getSendBegin()` when did the sending process begin
    `long` | `getSendTime()` time the transport tries to send the message (including any queueing)
    `long` | `getSeqNum()` For CDPQ
    `RouterInfo` | `getTarget()` Specifies the router to which the message should be delivered.
    `void` | `setEnqueueTime(long now)` For CDQ
    `void` | `setOnFailedReplyJob(Job job)`
    `void` | `setOnFailedSendJob(Job job)`
    `void` | `setOnReplyJob(ReplyJob job)`
    `void` | `setOnSendJob(Job job)`
    `void` | `setReplySelector(MessageSelector selector)`
    `void` | `setSeqNum(long num)` For CDPQ
    `void` | `timestamp(String eventName)` Stamp the message's progress.
    `String` | `toString()`
    `int` | `transportFailed(String transportStyle)` As of 0.9.55, returns the previous number of failed transports.

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

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

- - ### Field Detail

    - #### PRIORITY_BUILD_REPLY

          public static final int PRIORITY_BUILD_REPLY

      See Also:
        Constant Field Values

    - #### PRIORITY_EXPLORATORY

          public static final int PRIORITY_EXPLORATORY

      See Also:
        Constant Field Values

    - #### PRIORITY_HIGHEST

          public static final int PRIORITY_HIGHEST

      See Also:
        Constant Field Values

    - #### PRIORITY_HIS_BUILD_REQUEST

          public static final int PRIORITY_HIS_BUILD_REQUEST

      See Also:
        Constant Field Values

    - #### PRIORITY_HIS_NETDB_STORE

          public static final int PRIORITY_HIS_NETDB_STORE

      See Also:
        Constant Field Values

    - #### PRIORITY_LOWEST

          public static final int PRIORITY_LOWEST

      Priorities, higher is higher priority.
      See Also:
        Constant Field Values

    - #### PRIORITY_MEDIUM

          public static final int PRIORITY_MEDIUM

      See Also:
        Constant Field Values

    - #### PRIORITY_MY_BUILD_REQUEST

          public static final int PRIORITY_MY_BUILD_REQUEST

      See Also:
        Constant Field Values

    - #### PRIORITY_MY_DATA

          public static final int PRIORITY_MY_DATA

      See Also:
        Constant Field Values

    - #### PRIORITY_MY_NETDB_LOOKUP

          public static final int PRIORITY_MY_NETDB_LOOKUP

      See Also:
        Constant Field Values

    - #### PRIORITY_MY_NETDB_STORE

          public static final int PRIORITY_MY_NETDB_STORE

      See Also:
        Constant Field Values

    - #### PRIORITY_MY_NETDB_STORE_LOW

          public static final int PRIORITY_MY_NETDB_STORE_LOW

      See Also:
        Constant Field Values

    - #### PRIORITY_NETDB_EXPLORE

          public static final int PRIORITY_NETDB_EXPLORE

      See Also:
        Constant Field Values

    - #### PRIORITY_NETDB_FLOOD

          public static final int PRIORITY_NETDB_FLOOD

      See Also:
        Constant Field Values

    - #### PRIORITY_NETDB_HARVEST

          public static final int PRIORITY_NETDB_HARVEST

      See Also:
        Constant Field Values

    - #### PRIORITY_NETDB_REPLY

          public static final int PRIORITY_NETDB_REPLY

      See Also:
        Constant Field Values

    - #### PRIORITY_PARTICIPATING

          public static final int PRIORITY_PARTICIPATING

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### OutNetMessage

          public OutNetMessage(RouterContext context)

      Null msg and target, zero expiration (used in OutboundMessageRegistry only)

    - #### OutNetMessage

          public OutNetMessage(RouterContext context,
                               I2NPMessage msg,
                               long expiration,
                               int priority,
                               RouterInfo target)

      Standard constructor
      Parameters:
        `msg` - generally non-null
        `target` - generally non-null

  - ### Method Detail

    - #### beginSend

          public void beginSend()

    - #### discardData

          public void discardData()

      We've done what we need to do with the data from this message, though we may keep the object around for a while to use its ID, jobs, etc.

    - #### drop

          public void drop()

      For CDQ
      Specified by:
        `drop` in interface `CDQEntry`

    - #### getCreated

          public long getCreated()

    - #### getEnqueueTime

          public long getEnqueueTime()

      For CDQ
      Specified by:
        `getEnqueueTime` in interface `CDQEntry`

    - #### getExpiration

          public long getExpiration()

      Specify the # ms since the epoch after which if the message has not been sent the OnFailedSend job should be fired and the message should be removed from the pool. If the message has already been sent, this expiration is ignored and the expiration from the ReplySelector is used.

    - #### getFailedTransportCount

          public int getFailedTransportCount()

    - #### getFailedTransports

          public List<String> getFailedTransports()

      As of 0.9.55, changed from a Set to a List

    - #### getLifetime

          public long getLifetime()

      time since the message was created

    - #### getMessage

          public I2NPMessage getMessage()

      Specifies the message to be sent. Generally non-null but may be null in special cases.

    - #### getMessageData

          public int getMessageData(byte[] outBuffer)

      Copies the message data to outbuffer. Used only by VM Comm System.
      Returns:
        the length, or -1 if message is null

    - #### getMessageId

          public long getMessageId()

    - #### getMessageSize

          public int getMessageSize()

      How large the message is, including the full 16 byte header. Transports with different header sizes should adjust.

    - #### getMessageType

          public String getMessageType()

      For debugging only.
      Returns:
        the simple class name

    - #### getMessageTypeId

          public int getMessageTypeId()

    - #### getOnFailedReplyJob

          public Job getOnFailedReplyJob()

      If the Message selector is specified but it doesn't find a reply before its expiration passes, this job is enqueued.

    - #### getOnFailedSendJob

          public Job getOnFailedSendJob()

      If the router could not be reached or the expiration passed, this job is enqueued.

    - #### getOnReplyJob

          public ReplyJob getOnReplyJob()

      If the MessageSelector detects a reply, this job is enqueued

    - #### getOnSendJob

          public Job getOnSendJob()

      After the message is successfully passed to the router specified, the given job is enqueued.

    - #### getPriority

          public int getPriority()

      Specify the priority of the message, where higher numbers are higher priority. Higher priority messages should be delivered before lower priority ones, though some algorithm may be used to avoid starvation.
      Specified by:
        `getPriority` in interface `PQEntry`

    - #### getReplySelector

          public MessageSelector getReplySelector()

      Defines a MessageSelector to find a reply to this message.

    - #### getSendBegin

          public long getSendBegin()

      when did the sending process begin

    - #### getSendTime

          public long getSendTime()

      time the transport tries to send the message (including any queueing)

    - #### getSeqNum

          public long getSeqNum()

      For CDPQ
      Specified by:
        `getSeqNum` in interface `PQEntry`

    - #### getTarget

          public RouterInfo getTarget()

      Specifies the router to which the message should be delivered. Generally non-null but may be null in special cases.

    - #### setEnqueueTime

          public void setEnqueueTime(long now)

      For CDQ
      Specified by:
        `setEnqueueTime` in interface `CDQEntry`

    - #### setOnFailedReplyJob

          public void setOnFailedReplyJob(Job job)

    - #### setOnFailedSendJob

          public void setOnFailedSendJob(Job job)

    - #### setOnReplyJob

          public void setOnReplyJob(ReplyJob job)

    - #### setOnSendJob

          public void setOnSendJob(Job job)

    - #### setReplySelector

          public void setReplySelector(MessageSelector selector)

    - #### setSeqNum

          public void setSeqNum(long num)

      For CDPQ
      Specified by:
        `setSeqNum` in interface `PQEntry`

    - #### timestamp

          public void timestamp(String eventName)

      Stamp the message's progress. Only useful if log level is INFO or DEBUG
      Parameters:
        `eventName` - what occurred

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### transportFailed

          public int transportFailed(String transportStyle)

      As of 0.9.55, returns the previous number of failed transports.