java.lang.Object
net.i2p.data.i2cp.I2CPMessageImpl
net.i2p.data.i2cp.DisconnectMessage
All Implemented Interfaces:
I2CPMessage

public class DisconnectMessageextends I2CPMessageImpl
Defines the message a client sends to a router when destroying existing session.
  • Field Details

    • MESSAGE_TYPE

      public static final int MESSAGE_TYPE
      I2CP message type ID written to the wire header.
      See Also:
    • _reason

      private String _reason
      Why the router closed the connection, as shown to the client.
  • Constructor Details

    • DisconnectMessage

      public DisconnectMessage()
      Builds the disconnect with no reason; used by I2CP deserialization.
  • Method Details

    • getReason

      public String getReason()
      Reason the client gave for closing the session.
      Returns:
      the reason text, or null if the message was built without one
    • setReason

      public void setReason(String reason)
      Reason for the disconnect.
      Parameters:
      reason - the reason the client is closing the session, written into the message body and shown by the router in its session logs; null when no reason is given
    • doReadMessage

      protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException
      Read the message body from the input stream.
      Specified by:
      doReadMessage in class I2CPMessageImpl
      Parameters:
      in - positioned just past the 4 byte size and 1 byte type header
      size - how many payload bytes remain to be read
      Throws:
      I2CPMessageException - if the message format is invalid
      IOException - if there's an error reading from the stream
    • doWriteMessage

      protected byte[] doWriteMessage() throws I2CPMessageException, IOException
      Write the message body to the output stream.
      Specified by:
      doWriteMessage in class I2CPMessageImpl
      Returns:
      byte array
      Throws:
      I2CPMessageException - if the message cannot be written
      IOException - if there's an error writing to the stream
    • getType

      public int getType()
      I2CP message type sent for this message.
      Returns:
      the I2CP message type ID, always MESSAGE_TYPE
    • toString

      public String toString()
      Returns a string representation of this message.
      Overrides:
      toString in class Object