org.avineas.io.notify
public class NotifyingReadChannel<C extends ReadChannel> extends java.lang.Object implements ReadChannel, Notifier
Notifier.Listener| Constructor and Description |
|---|
NotifyingReadChannel(C wrapped,
int maxSize)
Add notification to a read channel.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
notify(Notifier.Listener toNotify)
Set the listener to notify when data is available.
|
int |
read(byte[] data,
int offset,
long timeout)
Read a packet or byte array from the channel, filling up either the data buffer or
the information as present in the packet.
|
public NotifyingReadChannel(C wrapped, int maxSize)
wrapped - The channel that is wrappedmaxSize - The max. size of packets that can appear on the wrapped channel. This size
is used to read packets from the wrapped channel via a separate threadpublic int read(byte[] data,
int offset,
long timeout)
ReadChannelread in interface ReadChanneldata - The byte buffer to read intooffset - The offset in the buffer to start readingtimeout - The timeout to wait for the first byte of data to become available, in ms.
If a value <= 0 is passed, no waiting is done at allpublic void close()
throws java.io.IOException
close in interface java.io.Closeablejava.io.IOExceptionpublic void notify(Notifier.Listener toNotify)
Notifier