java.lang.Object
net.i2p.data.i2cp.I2CPMessageImpl
net.i2p.data.i2cp.SessionStatusMessage
- All Implemented Interfaces:
I2CPMessage
Defines the message a router sends to a client indicating the status of the session.
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intI2CP message type of a session status report.static final intStatus code reporting that the session was created.static final intStatus code reporting that the session was destroyed.static final intUsed internally, not in spec, will be remapped to STATUS_INVALID before being sent.static final intStatus code reporting that the session is invalid.static final intSession refused status.static final intStatus code reporting that the session was updated.Constructor Summary
ConstructorsMethod Summary
All 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.Session id.intReturns the reported session status.intgetType()Returns the I2CP message type of this message.Return the SessionId for this message.voidSession ID for this message.final voidsetStatus(int status) Status of the session.toString()Returns a string representation of this message.Methods inherited from class I2CPMessageImpl
readBytes, readMessage, readMessage, writeBytes, writeMessageModifier and TypeMethodDescriptionvoidreadBytes(InputStream in) Read the message from the stream, wrapping I2CPMessageException in DataFormatException.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.voidwriteMessage(OutputStream out) Write out the full message to the stream, including the 4 byte size and 1 byte type header.
Field Details
MESSAGE_TYPE
public static final int MESSAGE_TYPEI2CP message type of a session status report.- See Also:
STATUS_DESTROYED
public static final int STATUS_DESTROYEDStatus code reporting that the session was destroyed.- See Also:
STATUS_CREATED
public static final int STATUS_CREATEDStatus code reporting that the session was created.- See Also:
STATUS_UPDATED
public static final int STATUS_UPDATEDStatus code reporting that the session was updated.- See Also:
STATUS_INVALID
public static final int STATUS_INVALIDStatus code reporting that the session is invalid.- See Also:
STATUS_REFUSED
STATUS_DUP_DEST
public static final int STATUS_DUP_DESTUsed internally, not in spec, will be remapped to STATUS_INVALID before being sent.- See Also:
Constructor Details
SessionStatusMessage
public SessionStatusMessage()Creates a message reporting the invalid status.
Method Details
getSessionId
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
Session ID for this message.- Parameters:
id- the session whose status this message reports
getStatus
public int getStatus()Returns the reported session status.- Returns:
- one of the STATUS_* constants describing the session's state
setStatus
public final void setStatus(int status) Status of the session.- Parameters:
status- one of the STATUS_* constants describing the session's current state
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
getType
public int getType()Returns the I2CP message type of this message.- Returns:
- SessionStatusMessage's I2CP type number, for dispatch
toString