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.

Author:
  jrandom

### Nested Class Summary

Nested Classes
`static interface` `I2CPMessageReader.I2CPMessageEventListener` Defines the different events the reader produces while reading the stream
`protected class` `I2CPMessageReader.I2CPMessageReaderRunner`

### Field Summary

Fields
`protected static long` `__readerId`
`protected I2CPMessageReader.I2CPMessageEventListener` `_listener`
`protected I2CPMessageReader.I2CPMessageReaderRunner` `_reader`
`protected Thread` `_readerThread`

### Constructor Summary

Constructors
`protected` `I2CPMessageReader(I2CPMessageReader.I2CPMessageEventListener lsnr)` For internal extension only.
`` `I2CPMessageReader(InputStream stream, I2CPMessageReader.I2CPMessageEventListener lsnr)`

### Method Summary

Methods
`I2CPMessageReader.I2CPMessageEventListener` `getListener()`
`void` `pauseReading()` Deprecated. unused
`void` `resumeReading()` Deprecated. unused
`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

#### _listener

    protected I2CPMessageReader.I2CPMessageEventListener _listener

#### _reader

    protected I2CPMessageReader.I2CPMessageReaderRunner _reader

#### _readerThread

    protected Thread _readerThread

#### __readerId

    protected static volatile long __readerId

### Constructor Detail

#### I2CPMessageReader

    public I2CPMessageReader(InputStream stream,
                     I2CPMessageReader.I2CPMessageEventListener lsnr)

#### I2CPMessageReader

    protected I2CPMessageReader(I2CPMessageReader.I2CPMessageEventListener lsnr)

For internal extension only. No stream.

Since:
  0.8.3

### Method Detail

#### setListener

    public void setListener(I2CPMessageReader.I2CPMessageEventListener lsnr)

#### getListener

    public I2CPMessageReader.I2CPMessageEventListener getListener()

#### startReading

    public void startReading()

Instruct the reader to begin reading messages off the stream

#### pauseReading

    public void pauseReading()

Deprecated. unused
Have the already started reader pause its reading indefinitely

#### resumeReading

    public void resumeReading()

Deprecated. unused
Resume reading after a pause

#### stopReading

    public void stopReading()

Cancel reading.