net.i2p.data.i2cp
Class SendMessageMessage

java.lang.Object
  extended by net.i2p.data.DataStructureImpl
      extended by net.i2p.data.i2cp.I2CPMessageImpl
          extended by net.i2p.data.i2cp.SendMessageMessage
All Implemented Interfaces:
Serializable, DataStructure, I2CPMessage
Direct Known Subclasses:
SendMessageExpiresMessage

public class SendMessageMessage
extends I2CPMessageImpl

Defines the message a client sends to a router to ask it to deliver a new message

Author:
jrandom
See Also:
Serialized Form

Field Summary
protected  Destination _destination
           
protected  long _nonce
           
protected  Payload _payload
           
protected  SessionId _sessionId
           
static int MESSAGE_TYPE
           
 
Constructor Summary
SendMessageMessage()
           
 
Method Summary
protected  void doReadMessage(InputStream in, int size)
          Read in the payload part of the message (after the initial 4 byte size and 1 byte type)
protected  byte[] doWriteMessage()
          Write out the payload part of the message (not including the 4 byte size and 1 byte type)
 Destination getDestination()
           
 long getNonce()
           
 Payload getPayload()
           
 SessionId getSessionId()
           
 int getType()
          Return the unique identifier for this type of message, as specified in the network specification document under #ClientAccessLayerMessages
 void readMessage(InputStream in, int length, int type)
          Read the body into the data structures
 SessionId sessionId()
          Return the SessionId for this message.
 void setDestination(Destination destination)
           
 void setNonce(long nonce)
           
 void setPayload(Payload payload)
           
 void setSessionId(SessionId id)
           
 String toString()
           
 void writeMessage(OutputStream out)
          Write out the full message to the stream, including the 4 byte size and 1 byte type header.
 
Methods inherited from class net.i2p.data.i2cp.I2CPMessageImpl
readBytes, readMessage, writeBytes
 
Methods inherited from class net.i2p.data.DataStructureImpl
calculateHash, fromBase64, fromByteArray, read, toBase64, toByteArray
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.i2p.data.DataStructure
calculateHash, fromBase64, fromByteArray, toBase64, toByteArray
 

Field Detail

MESSAGE_TYPE

public static final int MESSAGE_TYPE
See Also:
Constant Field Values

_sessionId

protected SessionId _sessionId

_destination

protected Destination _destination

_payload

protected Payload _payload

_nonce

protected long _nonce
Constructor Detail

SendMessageMessage

public SendMessageMessage()
Method Detail

getSessionId

public SessionId getSessionId()

sessionId

public SessionId sessionId()
Return the SessionId for this message.

Specified by:
sessionId in interface I2CPMessage
Overrides:
sessionId in class I2CPMessageImpl
Returns:
null always. Extending classes with a SessionId must override.
Since:
0.9.21

setSessionId

public void setSessionId(SessionId id)

getDestination

public Destination getDestination()

setDestination

public void setDestination(Destination destination)

getPayload

public Payload getPayload()

setPayload

public void setPayload(Payload payload)

getNonce

public long getNonce()
Returns:
0 to 0xffffffff

setNonce

public void setNonce(long nonce)
Parameters:
nonce - 0 to 0xffffffff

doReadMessage

protected void doReadMessage(InputStream in,
                             int size)
                      throws I2CPMessageException,
                             IOException
Description copied from class: I2CPMessageImpl
Read in the payload part of the message (after the initial 4 byte size and 1 byte type)

Specified by:
doReadMessage in class I2CPMessageImpl
Parameters:
in - InputStream
size - payload size
Throws:
I2CPMessageException
IOException

readMessage

public void readMessage(InputStream in,
                        int length,
                        int type)
                 throws I2CPMessageException,
                        IOException
Read the body into the data structures

Specified by:
readMessage in interface I2CPMessage
Overrides:
readMessage in class I2CPMessageImpl
Parameters:
in - stream to read from
length - number of bytes in the message payload
type - type of message (should equal getType())
Throws:
IOException
I2CPMessageException - if the stream doesn't contain a valid message that this class can read.

doWriteMessage

protected byte[] doWriteMessage()
                         throws I2CPMessageException,
                                IOException
Description copied from class: I2CPMessageImpl
Write out the payload part of the message (not including the 4 byte size and 1 byte type)

Specified by:
doWriteMessage in class I2CPMessageImpl
Returns:
byte array
Throws:
UnsupportedOperationException - always
I2CPMessageException
IOException

writeMessage

public void writeMessage(OutputStream out)
                  throws I2CPMessageException,
                         IOException
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:
writeMessage in interface I2CPMessage
Overrides:
writeMessage in class I2CPMessageImpl
Parameters:
out - OutputStream
Throws:
IOException
I2CPMessageException - if the current object doesn't have sufficient data to write a properly formatted message.

getType

public int getType()
Description copied from interface: I2CPMessage
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

public String toString()
Overrides:
toString in class Object