Interface Message

All Known Subinterfaces:
RawMessage
All Known Implementing Classes:
BTMessageCancel, BTMessagePiece, BTMessageRequest, MessageAdapter, RawMessageAdapter

public interface Message
Basic peer message. A message is uniquely identified by the combination of ID and version.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Is a data-bearing message, i.e.
    static final int
    Is a protocol-bearing message, i.e.
  • Method Summary

    Modifier and Type
    Method
    Description
    Create a new instance of this message by decoding the given byte serialization.
    void
    Destroy the message; i.e.
    Get textual description of this particular message.
    Get message id.
    Get message payload data.
    int
    Get message type.
  • Field Details

    • TYPE_PROTOCOL_PAYLOAD

      static final int TYPE_PROTOCOL_PAYLOAD
      Is a protocol-bearing message, i.e. messaging/overhead data.
      See Also:
    • TYPE_DATA_PAYLOAD

      static final int TYPE_DATA_PAYLOAD
      Is a data-bearing message, i.e. file data.
      See Also:
  • Method Details

    • getID

      String getID()
      Get message id.
      Returns:
      id
    • getType

      int getType()
      Get message type.
      Returns:
      type
    • getDescription

      String getDescription()
      Get textual description of this particular message.
      Returns:
      description
    • getPayload

      ByteBuffer[] getPayload()
      Get message payload data.
      Returns:
      message data buffers
    • create

      Message create(ByteBuffer data) throws MessageException
      Create a new instance of this message by decoding the given byte serialization.
      Parameters:
      data - to deserialize
      Returns:
      decoded message instance
      Throws:
      MessageException - if the decoding process fails
    • destroy

      void destroy()
      Destroy the message; i.e. perform cleanup actions.