net.i2p.data.i2cp

## Class I2CPMessageReader

- java.lang.Object
- - net.i2p.data.i2cp.I2CPMessageReader

- Direct Known Subclasses:
    QueuedI2CPMessageReader

      public class I2CPMessageReader
      extends Object

  The I2CPMessageReader reads an InputStream (using `I2CPMessageHandler`) and passes out events to a registered listener, where events are either messages being received, exceptions being thrown, or the connection being closed. Applications should use this rather than read from the stream themselves.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static interface` | `I2CPMessageReader.I2CPMessageEventListener` Defines the different events the reader produces while reading the stream
    `protected class` | `I2CPMessageReader.I2CPMessageReaderRunner`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static AtomicLong` | `__readerId`
    `protected I2CPMessageReader.I2CPMessageEventListener` | `_listener`
    `protected I2CPMessageReader.I2CPMessageReaderRunner` | `_reader`
    `protected Thread` | `_readerThread`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `I2CPMessageReader(I2CPMessageReader.I2CPMessageEventListener lsnr)` For internal extension only.
    `` | `I2CPMessageReader(InputStream stream, I2CPMessageReader.I2CPMessageEventListener lsnr)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `I2CPMessageReader.I2CPMessageEventListener` | `getListener()`
    `void` | `setListener(I2CPMessageReader.I2CPMessageEventListener lsnr)`
    `void` | `startReading()` Instruct the reader to begin reading messages off the stream
    `void` | `stopReading()` Cancel reading.

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

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

- - ### Field Detail

    - #### __readerId

          protected static final AtomicLong __readerId

    - #### _listener

          protected I2CPMessageReader.I2CPMessageEventListener _listener

    - #### _reader

          protected I2CPMessageReader.I2CPMessageReaderRunner _reader

    - #### _readerThread

          protected Thread _readerThread

  - ### Constructor Detail

    - #### I2CPMessageReader

          protected I2CPMessageReader(I2CPMessageReader.I2CPMessageEventListener lsnr)

      For internal extension only. No stream.

    - #### I2CPMessageReader

          public I2CPMessageReader(InputStream stream,
                                   I2CPMessageReader.I2CPMessageEventListener lsnr)

  - ### Method Detail

    - #### getListener

          public I2CPMessageReader.I2CPMessageEventListener getListener()

    - #### setListener

          public void setListener(I2CPMessageReader.I2CPMessageEventListener lsnr)

    - #### startReading

          public void startReading()

      Instruct the reader to begin reading messages off the stream

    - #### stopReading

          public void stopReading()

      Cancel reading.