net.i2p.client.impl

## Class MessageState

- java.lang.Object
- - net.i2p.client.impl.MessageState

-     class MessageState
      extends Object

  Contains the state of a payload message being sent to a peer. Originally was a general-purpose waiter. Then we got rid of guaranteed delivery. Then we stopped waiting for accept in best-effort delivery. Brought back to life for asynchronous status delivery to the client.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `MessageState(I2PAppContext ctx, long nonce, I2PSession session, long expires, SendMessageStatusListener listener)` For asynchronous notification
    `MessageState(I2PAppContext ctx, long nonce, String prefix)` For synchronous waiting for accept with waitForAccept().

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `cancel()`
    `long` | `getElapsed()`
    `long` | `getExpires()`
    `MessageId` | `getMessageId()`
    `void` | `receive(int status)`
    `void` | `setMessageId(MessageId id)`
    `void` | `waitForAccept(long expiration)` For guaranteed/best effort only.
    `boolean` | `wasAccepted()`
    `boolean` | `wasSuccessful()`

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

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

- - ### Constructor Detail

    - #### MessageState

          public MessageState(I2PAppContext ctx,
                              long nonce,
                              I2PSession session,
                              long expires,
                              SendMessageStatusListener listener)

      For asynchronous notification
      Parameters:
        `expires` - absolute time (not interval)

    - #### MessageState

          public MessageState(I2PAppContext ctx,
                              long nonce,
                              String prefix)

      For synchronous waiting for accept with waitForAccept(). UNUSED.

  - ### Method Detail

    - #### cancel

          public void cancel()

    - #### getElapsed

          public long getElapsed()

    - #### getExpires

          public long getExpires()

    - #### getMessageId

          public MessageId getMessageId()

    - #### receive

          public void receive(int status)

    - #### setMessageId

          public void setMessageId(MessageId id)

    - #### waitForAccept

          public void waitForAccept(long expiration)
                             throws InterruptedException

      For guaranteed/best effort only. Not really used.
      Throws:
        `InterruptedException`

    - #### wasAccepted

          public boolean wasAccepted()

      Returns:
        true if accepted (fixme and not failed)

    - #### wasSuccessful

          public boolean wasSuccessful()

      Returns:
        true if successful