## net.i2p.client.streaming
Class MessageInputStream

    java.lang.Object
      java.io.InputStream
          net.i2p.client.streaming.MessageInputStream

All Implemented Interfaces:
  java.io.Closeable

    public class MessageInputStream

extends java.io.InputStream

Stream that can be given messages out of order yet present them in order.

Constructor Summary
`MessageInputStream(I2PAppContext ctx)`

Method Summary
`int` `available()`
`void` `close()`
`void` `closeReceived()`
`long` `getHighestBlockId()`
`long` `getHighestReadyBockId()` What is the highest block ID we've completely received through?
`long[]` `getNacks()` Retrieve the message IDs that are holes in our sequence - ones past the highest ready ID and below the highest received message ID.
`int` `getOutOfOrderBlockCount()` how many blocks have we received that we still have holes before?
`long[]` `getOutOfOrderBlocks()` Ascending list of block IDs greater than the highest ready block ID, or null if there aren't any.
`int` `getReadTimeout()` how long a read() call should block (if less than 0, block indefinitely, but if it is 0, do not block at all)
`int` `getTotalQueuedSize()` How many bytes are queued up for reading (or sitting in the out-of-order buffer)?
`int` `getTotalReadySize()`
`boolean` `messageReceived(long messageId, ByteArray payload)` A new message has arrived - toss it on the appropriate queue (moving previously pending messages to the ready queue if it fills the gap, etc).
`void` `notifyActivity()`
`int` `read()`
`int` `read(byte[] target)`
`int` `read(byte[] target, int offset, int length)`
`void` `setReadTimeout(int timeout)`
`(package private) void` `streamErrorOccurred(java.io.IOException ioe)` Stream b0rked, die with the given error
`void` `updateAcks(PacketLocal packet)`

Methods inherited from class java.io.InputStream
`mark, markSupported, reset, skip`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### MessageInputStream

    public MessageInputStream(I2PAppContext ctx)

Method Detail

### getHighestReadyBockId

    public long getHighestReadyBockId()

  What is the highest block ID we've completely received through?

### getHighestBlockId

    public long getHighestBlockId()

### getNacks

    public long[] getNacks()

  Retrieve the message IDs that are holes in our sequence - ones past the highest ready ID and below the highest received message ID. This may return null if there are no such IDs.

### updateAcks

    public void updateAcks(PacketLocal packet)

### getOutOfOrderBlocks

    public long[] getOutOfOrderBlocks()

  Ascending list of block IDs greater than the highest ready block ID, or null if there aren't any.

### getOutOfOrderBlockCount

    public int getOutOfOrderBlockCount()

  how many blocks have we received that we still have holes before?

### getReadTimeout

    public int getReadTimeout()

  how long a read() call should block (if less than 0, block indefinitely, but if it is 0, do not block at all)

### setReadTimeout

    public void setReadTimeout(int timeout)

### closeReceived

    public void closeReceived()

### notifyActivity

    public void notifyActivity()

### messageReceived

    public boolean messageReceived(long messageId,
                                   ByteArray payload)

  A new message has arrived - toss it on the appropriate queue (moving previously pending messages to the ready queue if it fills the gap, etc).

  Returns:
    true if this is a new packet, false if it is a dup

### read

    public int read()
             throws java.io.IOException

  Specified by:
    `read` in class `java.io.InputStream`
  Throws:
    `java.io.IOException`

### read

    public int read(byte[] target)
             throws java.io.IOException

  Overrides:
    `read` in class `java.io.InputStream`
  Throws:
    `java.io.IOException`

### read

    public int read(byte[] target,
                    int offset,
                    int length)
             throws java.io.IOException

  Overrides:
    `read` in class `java.io.InputStream`
  Throws:
    `java.io.IOException`

### available

    public int available()
                  throws java.io.IOException

  Overrides:
    `available` in class `java.io.InputStream`
  Throws:
    `java.io.IOException`

### getTotalQueuedSize

    public int getTotalQueuedSize()

  How many bytes are queued up for reading (or sitting in the out-of-order buffer)?

### getTotalReadySize

    public int getTotalReadySize()

### close

    public void close()

  Specified by:
    `close` in interface `java.io.Closeable`
  Overrides:
    `close` in class `java.io.InputStream`

### streamErrorOccurred

    void streamErrorOccurred(java.io.IOException ioe)

  Stream b0rked, die with the given error