class MessageInputStream extends InputStream
I2PSession -> MessageHandler -> PacketHandler -> ConnectionPacketHandler -> MessageInputStream
This buffers unlimited data via messageReceived() - limiting / blocking is done in ConnectionPacketHandler.receivePacket().
Constructor and Description |
---|
MessageInputStream(I2PAppContext ctx,
int maxMessageSize,
int maxWindowSize,
int maxBufferSize) |
Modifier and Type | Method and Description |
---|---|
int |
available() |
boolean |
canAccept(long messageId,
int payloadSize)
Determine if this packet will fit in our buffering limits.
|
void |
close() |
void |
closeReceived()
There is no more data coming from the I2P side.
|
long |
getHighestBlockId() |
long |
getHighestReadyBlockId()
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 |
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 |
getTotalReadySize()
Same as available() but doesn't throw IOE
|
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()
On a read timeout, this returns -1
(doesn't throw SocketTimeoutException like Socket)
(doesn't throw InterruptedIOException like our javadocs say)
|
int |
read(byte[] target)
On a read timeout, this returns 0
(doesn't throw SocketTimeoutException like Socket)
(doesn't throw InterruptedIOException like our javadocs say)
|
int |
read(byte[] target,
int offset,
int length)
On a read timeout, this returns 0
(doesn't throw SocketTimeoutException like Socket)
(doesn't throw InterruptedIOException like our javadocs say)
|
void |
setReadTimeout(int timeout)
how long a read() call should block (if less than 0, block indefinitely,
but if it is 0, do not block at all)
|
(package private) void |
streamErrorOccurred(IOException ioe)
Stream b0rked, die with the given error
|
void |
updateAcks(PacketLocal packet)
Adds the ack-through and nack fields to a packet we are building for transmission
|
mark, markSupported, reset, skip
public MessageInputStream(I2PAppContext ctx, int maxMessageSize, int maxWindowSize, int maxBufferSize)
public long getHighestReadyBlockId()
public long getHighestBlockId()
public boolean canAccept(long messageId, int payloadSize)
public long[] getNacks()
public void updateAcks(PacketLocal packet)
public int getReadTimeout()
public void setReadTimeout(int timeout)
timeout
- how long read calls should block, 0 for nonblocking, negative to indefinitely blockpublic void closeReceived()
public void notifyActivity()
public boolean messageReceived(long messageId, ByteArray payload)
messageId
- ID of the messagepayload
- message payload, may be null or have null or zero-length datapublic int read() throws IOException
read
in class InputStream
IOException
public int read(byte[] target) throws IOException
read
in class InputStream
IOException
public int read(byte[] target, int offset, int length) throws IOException
read
in class InputStream
IOException
public int available() throws IOException
available
in class InputStream
IOException
public int getTotalReadySize()
public void close()
close
in interface Closeable
close
in interface AutoCloseable
close
in class InputStream
void streamErrorOccurred(IOException ioe)