net.i2p.data.i2np
Class I2NPMessageHandler

java.lang.Object
  extended by net.i2p.data.i2np.I2NPMessageHandler

public class I2NPMessageHandler
extends Object

Handle messages from router to router. This class is NOT threadsafe


Constructor Summary
I2NPMessageHandler(I2PAppContext context)
           
 
Method Summary
 long getLastReadTime()
           
 int getLastSize()
           
 I2NPMessage lastRead()
          clear the last message read from a byte array with an offset
 I2NPMessage readMessage(byte[] data)
          Read an I2NPMessage from the byte array and return the fully populated object.
 int readMessage(byte[] data, int offset)
          Result is retreived with lastRead()
 int readMessage(byte[] data, int offset, int maxLen)
          Set a limit on the max to read from the data buffer, so that we can use a large buffer but prevent the reader from reading off the end.
 I2NPMessage readMessage(InputStream in)
          Deprecated. use the byte array method to avoid an extra copy if you have it
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

I2NPMessageHandler

public I2NPMessageHandler(I2PAppContext context)
Method Detail

readMessage

public I2NPMessage readMessage(InputStream in)
                        throws IOException,
                               I2NPMessageException
Deprecated. use the byte array method to avoid an extra copy if you have it

Read an I2NPMessage from the stream and return the fully populated object. This is only called by I2NPMessageReader which is unused. All transports provide encapsulation and so we have byte arrays available.

Throws:
I2NPMessageException - if there is a problem handling the particular message - if it is an unknown type or has improper formatting, etc.
IOException

lastRead

public I2NPMessage lastRead()
clear the last message read from a byte array with an offset


readMessage

public I2NPMessage readMessage(byte[] data)
                        throws I2NPMessageException
Read an I2NPMessage from the byte array and return the fully populated object.

Throws:
I2NPMessageException - if there is a problem handling the particular message - if it is an unknown type or has improper formatting, etc.

readMessage

public int readMessage(byte[] data,
                       int offset)
                throws I2NPMessageException
Result is retreived with lastRead()

Throws:
I2NPMessageException

readMessage

public int readMessage(byte[] data,
                       int offset,
                       int maxLen)
                throws I2NPMessageException
Set a limit on the max to read from the data buffer, so that we can use a large buffer but prevent the reader from reading off the end. Result is retreived with lastRead()

Parameters:
maxLen - read no more than this many bytes from data starting at offset, even if it is longer must be at least 16
Throws:
I2NPMessageException
Since:
0.8.12

getLastReadTime

public long getLastReadTime()

getLastSize

public int getLastSize()