Class BTMessageDecoder

    • Field Detail

      • decode_array

        private final java.nio.ByteBuffer[] decode_array
      • reading_length_mode

        private boolean reading_length_mode
      • reading_handshake_message

        private boolean reading_handshake_message
      • message_length

        private int message_length
      • pre_read_start_buffer

        private int pre_read_start_buffer
      • pre_read_start_position

        private int pre_read_start_position
      • last_received_was_keepalive

        private boolean last_received_was_keepalive
      • destroyed

        private volatile boolean destroyed
      • is_paused

        private volatile boolean is_paused
      • messages_last_read

        private final java.util.ArrayList messages_last_read
      • protocol_bytes_last_read

        private int protocol_bytes_last_read
      • data_bytes_last_read

        private int data_bytes_last_read
      • percent_complete

        private int percent_complete
    • Constructor Detail

      • BTMessageDecoder

        public BTMessageDecoder()
    • Method Detail

      • performStreamDecode

        public int performStreamDecode​(Transport transport,
                                       int max_bytes)
                                throws java.io.IOException
        Description copied from interface: MessageStreamDecoder
        Decode message stream from the given transport.
        Specified by:
        performStreamDecode in interface MessageStreamDecoder
        Parameters:
        transport - to decode from
        max_bytes - to decode/read from the stream
        Returns:
        number of bytes decoded
        Throws:
        java.io.IOException - on decoding error
      • getPercentDoneOfCurrentMessage

        public int getPercentDoneOfCurrentMessage()
        Description copied from interface: MessageStreamDecoder
        Get the percentage of the current message that has already been received (read from the transport).
        Specified by:
        getPercentDoneOfCurrentMessage in interface MessageStreamDecoder
        Returns:
        percentage complete (0-99), or -1 if no message is currently being received
      • removeDecodedMessages

        public Message[] removeDecodedMessages()
        Description copied from interface: MessageStreamDecoder
        Get the messages decoded from the transport, if any, from the last decode op.
        Specified by:
        removeDecodedMessages in interface MessageStreamDecoder
        Returns:
        decoded messages, or null if no new complete messages were decoded
      • getProtocolBytesDecoded

        public int getProtocolBytesDecoded()
        Description copied from interface: MessageStreamDecoder
        Get the number of protocol (overhead) bytes decoded from the transport, from the last decode op.
        Specified by:
        getProtocolBytesDecoded in interface MessageStreamDecoder
        Returns:
        number of protocol bytes recevied
      • getDataBytesDecoded

        public int getDataBytesDecoded()
        Description copied from interface: MessageStreamDecoder
        Get the number of (piece) data bytes decoded from the transport, from the last decode op.
        Specified by:
        getDataBytesDecoded in interface MessageStreamDecoder
        Returns:
        number of data bytes received
      • destroy

        public java.nio.ByteBuffer destroy()
        Description copied from interface: MessageStreamDecoder
        Destroy this decoder, i.e. perform cleanup.
        Specified by:
        destroy in interface MessageStreamDecoder
        Returns:
        any bytes already-read and still remaining within the decoder
      • preReadProcess

        private int preReadProcess​(int allowed)
      • postReadProcess

        private int postReadProcess()
                             throws java.io.IOException
        Throws:
        java.io.IOException