java.lang.Object
net.i2p.data.i2cp.I2CPMessageImpl
net.i2p.data.i2cp.ReceiveMessageBeginMessage
- All Implemented Interfaces:
I2CPMessage
Defines the message a client sends to a router when asking the router to start sending a message to it.
Field Summary
Modifier and TypeFieldDescriptionprivate longThe message ID.private intThe session ID.static final intI2CP message type number identifying the start of an incoming message.Constructor Summary
ConstructorsMethod Summary
Public MethodsModifier and TypeMethodDescriptionprotected voiddoReadMessage(InputStream in, int size) Read the message body from the input stream.protected byte[]Write the message body to the output stream.longMessage identifier for delivery tracking.longSession identifier for this message.intgetType()Reports this message's I2CP type number.Return the SessionId for this message.voidsetMessageId(long id) Message identifier for delivery tracking.voidsetSessionId(long id) Set the session the message is addressed to.toString()Returns a string representation of this message.voidwriteMessage(OutputStream out) Override to reduce mem churn.Methods inherited from class I2CPMessageImpl
readBytes, readMessage, readMessage, writeBytesModifier and TypeMethodDescriptionvoidreadBytes(InputStream in) Read the message from the stream, wrapping I2CPMessageException inDataFormatException.voidValidate the type and size of the message, and then read the message into the data structures.voidreadMessage(InputStream in, int length, int type) Read the body into the data structures.voidwriteBytes(OutputStream out) Write the message to the stream, wrapping I2CPMessageException in DataFormatException.
Field Details
MESSAGE_TYPE
public static final int MESSAGE_TYPEI2CP message type number identifying the start of an incoming message.- See Also:
_sessionId
private int _sessionIdThe session ID._messageId
private long _messageIdThe message ID.
Constructor Details
ReceiveMessageBeginMessage
public ReceiveMessageBeginMessage()Creates a message with an invalid session id.
Method Details
getSessionId
public long getSessionId()Session identifier for this message.- Returns:
- the session ID
sessionId
Return the SessionId for this message.- Specified by:
sessionIdin interfaceI2CPMessage- Overrides:
sessionIdin classI2CPMessageImpl- Returns:
- null always. Extending classes with a SessionId must override.
setSessionId
public void setSessionId(long id) Set the session the message is addressed to.- Parameters:
id- 0-65535
getMessageId
public long getMessageId()Message identifier for delivery tracking.- Returns:
- the message ID
setMessageId
public void setMessageId(long id) Message identifier for delivery tracking.- Parameters:
id- the message ID
doReadMessage
Read the message body from the input stream.- Specified by:
doReadMessagein classI2CPMessageImpl- Parameters:
in- positioned just past the 4 byte size and 1 byte type headersize- how many payload bytes remain to be read- Throws:
I2CPMessageException- if the message format is invalidIOException- if there's an error reading from the stream
doWriteMessage
Write the message body to the output stream.- Specified by:
doWriteMessagein classI2CPMessageImpl- Returns:
- byte array
- Throws:
I2CPMessageException- if the message cannot be writtenIOException- if there's an error writing to the stream
writeMessage
Override to reduce mem churn.- Specified by:
writeMessagein interfaceI2CPMessage- Overrides:
writeMessagein classI2CPMessageImpl- Parameters:
out- receives the length, type and payload, in that order- Throws:
IOException- on write errorI2CPMessageException- if the current object doesn't have sufficient data to write a properly formatted message.
getType
toString