Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## net.i2p.client.streaming
Class MessageInputStream

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

All Implemented Interfaces:
  Closeable

     class MessageInputStream

extends 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(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?

  Returns:
    highest data block ID completely received

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

  Returns:
    array of message ID holes, or null if none

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

  Returns:
    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?

  Returns:
    Count of blocks received that still have holes

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

  Returns:
    how long read calls should block, 0 or less indefinitely block

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

  Parameters:
    `messageId` - ID of the message
    `payload` - message payload
  Returns:
    true if this is a new packet, false if it is a dup

### read

    public int read()
             throws IOException

  Specified by:
    `read` in class `InputStream`
  Throws:
    `IOException`

### read

    public int read(byte[] target)
             throws IOException

  Overrides:
    `read` in class `InputStream`
  Throws:
    `IOException`

### read

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

  Overrides:
    `read` in class `InputStream`
  Throws:
    `IOException`

### available

    public int available()
                  throws IOException

  Overrides:
    `available` in class `InputStream`
  Throws:
    `IOException`

### getTotalQueuedSize

    public int getTotalQueuedSize()

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

  Returns:
    Count of bytes waiting to be read

### getTotalReadySize

    public int getTotalReadySize()

### close

    public void close()

  Specified by:
    `close` in interface `Closeable`
  Overrides:
    `close` in class `InputStream`

### streamErrorOccurred

    void streamErrorOccurred(IOException ioe)

  Stream b0rked, die with the given error

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD