java.lang.Object
net.i2p.data.i2cp.I2CPMessageImpl
net.i2p.data.i2cp.SendMessageMessage
- All Implemented Interfaces:
I2CPMessage
- Direct Known Subclasses:
SendMessageExpiresMessage
Defines the message a client sends to a router to ask it to deliver a new message.
Field Summary
FieldsModifier and TypeFieldDescriptionprotected DestinationDestination the payload is addressed to.protected longClient replay nonce, echoed back in the RejectMessage.protected PayloadData to deliver to that destination.protected SessionIdSession the payload is being sent over.static final intI2CP message type ID written to the wire header.Constructor Summary
ConstructorsConstructorDescriptionFor reading.SendMessageMessage(SessionId sessID, Destination dest, Payload payload, long nonce) For writing.Method Summary
Public MethodsModifier and TypeMethodDescriptionprotected voiddoReadMessage(InputStream in, int size) Read in the payload part of the message (after the initial 4 byte size and 1 byte type).protected byte[]Serialization is not supported for this message.Destination the message is being sent to.longgetNonce()Message nonce.Message payload being sent.Session ID the message is being sent to.intgetType()Return the unique identifier for this type of message, as specified in the network specification document under #ClientAccessLayerMessages.voidreadMessage(InputStream in, int length, int type) Read the body into the data structures.Return the SessionId for this message.toString()voidwriteMessage(OutputStream out) Write out the full message to the stream, including the 4 byte size and 1 byte type header.Methods inherited from class I2CPMessageImpl
readBytes, 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.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 ID written to the wire header.- See Also:
_sessionId
Session the payload is being sent over._destination
Destination the payload is addressed to._payload
Data to deliver to that destination._nonce
protected long _nonceClient replay nonce, echoed back in the RejectMessage.
Constructor Details
SendMessageMessage
public SendMessageMessage()For reading. Deprecated for writing, use 4-arg constructor.SendMessageMessage
For writing.- Parameters:
sessID- the session the message is to be sent overdest- the destination to address the payload topayload- the data to deliver to that destinationnonce- the client's replay nonce, echoed back in the RejectMessage
Method Details
getSessionId
Session ID the message is being sent to.- Returns:
- the session this message belongs to
sessionId
Return the SessionId for this message.- Specified by:
sessionIdin interfaceI2CPMessage- Overrides:
sessionIdin classI2CPMessageImpl- Returns:
- null always. Extending classes with a SessionId must override.
getDestination
Destination the message is being sent to.- Returns:
- the peer the message is addressed to, or null if unset
getPayload
Message payload being sent.- Returns:
- the data to deliver to the destination, or null if unset
getNonce
public long getNonce()Message nonce.- Returns:
- 0 to 0xffffffff
doReadMessage
Read in the payload part of the message (after the initial 4 byte size and 1 byte type).- 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
readMessage
public void readMessage(InputStream in, int length, int type) throws I2CPMessageException, IOException Read the body into the data structures.- Specified by:
readMessagein interfaceI2CPMessage- Overrides:
readMessagein classI2CPMessageImpl- Parameters:
in- stream to read fromlength- number of bytes in the message payloadtype- type of message (should equalI2CPMessage.getType())- Throws:
IOException- if there's an error reading from the streamI2CPMessageException- if the stream doesn't contain a valid message that this class can read.
doWriteMessage
Serialization is not supported for this message.- Specified by:
doWriteMessagein classI2CPMessageImpl- Returns:
- byte array
- Throws:
UnsupportedOperationException- always; use writeMessage insteadI2CPMessageException- if the message cannot be writtenIOException- if there's an error writing to the stream
writeMessage
Write out the full message to the stream, including the 4 byte size and 1 byte type header. Override the parent so we can be more mem efficient.- Specified by:
writeMessagein interfaceI2CPMessage- Overrides:
writeMessagein classI2CPMessageImpl- Parameters:
out- receives the length, type and payload, in that order- Throws:
IOException- if there's an error writing to the streamI2CPMessageException- if the current object doesn't have sufficient data to write a properly formatted message.
getType
public int getType()Return the unique identifier for this type of message, as specified in the network specification document under #ClientAccessLayerMessages.- Returns:
- unique identifier for this type of message
toString