public abstract class I2CPMessageImpl extends Object implements I2CPMessage
| Constructor and Description |
|---|
I2CPMessageImpl() |
| Modifier and Type | Method and Description |
|---|---|
protected abstract void |
doReadMessage(InputStream buf,
int size)
Read in the payload part of the message (after the initial 4 byte size and 1
byte type)
|
protected abstract byte[] |
doWriteMessage()
Write out the payload part of the message (not including the 4 byte size and
1 byte type)
|
void |
readBytes(InputStream in) |
void |
readMessage(InputStream in)
Validate the type and size of the message, and then read the message into the data structures.
|
void |
readMessage(InputStream in,
int length,
int type)
Read the body into the data structures
|
SessionId |
sessionId()
Return the SessionId for this type of message.
|
void |
writeBytes(OutputStream out) |
void |
writeMessage(OutputStream out)
Write out the full message to the stream, including the 4 byte size and 1
byte type header.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetTypeprotected abstract void doReadMessage(InputStream buf, int size) throws I2CPMessageException, IOException
buf - InputStreamsize - payload sizeI2CPMessageException - if the message format is invalidIOException - if there's an error reading from the streamprotected abstract byte[] doWriteMessage()
throws I2CPMessageException,
IOException
I2CPMessageException - if the message cannot be writtenIOException - if there's an error writing to the streampublic void readBytes(InputStream in) throws DataFormatException, IOException
DataFormatExceptionIOExceptionpublic void readMessage(InputStream in) throws I2CPMessageException, IOException
readMessage in interface I2CPMessagein - stream to read fromIOException - if there's an error reading from the streamI2CPMessageException - if the stream doesn't contain a valid message
that this class can read.public void readMessage(InputStream in, int length, int type) throws I2CPMessageException, IOException
readMessage in interface I2CPMessagelength - number of bytes in the message payloadin - stream to read fromtype - type of message (should equal getType())IOException - if there's an error reading from the streamI2CPMessageException - if the stream doesn't contain a valid message
that this class can read.public SessionId sessionId()
sessionId in interface I2CPMessagepublic void writeBytes(OutputStream out) throws DataFormatException, IOException
DataFormatExceptionIOExceptionpublic void writeMessage(OutputStream out) throws I2CPMessageException, IOException
writeMessage in interface I2CPMessageout - OutputStreamIOException - if there's an error writing to the streamI2CPMessageException - if the current object doesn't have sufficient data
to write a properly formatted message.