java.lang.Object
net.i2p.data.i2cp.I2CPMessageReader
- Direct Known Subclasses:
QueuedI2CPMessageReader
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 ClassesModifier and TypeClassDescriptionstatic interfaceDefines the different events the reader produces while reading the stream.protected classI2CPMessageReaderRunner.Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final AtomicLongSource of the unique suffix each reader thread name carries.Listener notified of incoming messages, read errors and disconnects.Runnable doing the reading, owned by the reader thread.protected ThreadThread running the read loop.private InputStreamStream the messages are read from.Constructor Summary
ConstructorsModifierConstructorDescriptionI2CPMessageReader.protectedFor internal extension only.Method Summary
All MethodsModifier and TypeMethodDescriptionCurrent message event listener.final voidListener for message events.voidInstruct the reader to begin reading messages off the stream.voidCancel reading.
Field Details
_stream
Stream the messages are read from._listener
Listener notified of incoming messages, read errors and disconnects._reader
Runnable doing the reading, owned by the reader thread._readerThread
Thread running the read loop.__readerId
Source of the unique suffix each reader thread name carries.
Constructor Details
I2CPMessageReader
I2CPMessageReader.- Parameters:
stream- the stream to read length-prefixed I2CP messages fromlsnr- the listener notified of messages, errors and disconnects
I2CPMessageReader
For internal extension only. No stream.- Parameters:
lsnr- the listener to notify of messages, errors and disconnects
Method Details
setListener
Listener for message events.- Parameters:
lsnr- the listener to notify of messages, errors and disconnects
getListener
Current message event listener.- Returns:
- the listener passed to the constructor or
setListener(I2CPMessageReader.I2CPMessageEventListener), notified of messages, errors and disconnects read from the stream
startReading
public void startReading()Instruct the reader to begin reading messages off the stream.stopReading
public void stopReading()Cancel reading.