Class BTMessageDecoder
java.lang.Object
com.biglybt.core.peermanager.messaging.bittorrent.BTMessageDecoder
- All Implemented Interfaces:
MessageStreamDecoder
- Direct Known Subclasses:
LTMessageDecoder
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intprivate final ByteBuffer[]private booleanprivate static final intprivate booleanprivate booleanprivate final DirectByteBufferprivate static final intprivate intprivate final ArrayListprivate static final intprivate DirectByteBufferprivate intprivate intprivate int[]private intprivate intprivate booleanprivate booleanprivate static final byte -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected MessagecreateMessage(DirectByteBuffer ref_buff) destroy()Destroy this decoder, i.e.int[]Get the details of the current message that is being received (read from the transport).intGet the number of (piece) data bytes decoded from the transport, from the last decode op.intGet the number of protocol (overhead) bytes decoded from the transport, from the last decode op.voidPause message decoding.longperformStreamDecode(Transport transport, long max_bytes) Decode message stream from the given transport.private intprivate longpreReadProcess(long allowed) Message[]Get the messages decoded from the transport, if any, from the last decode op.voidResume message decoding.
-
Field Details
-
MIN_MESSAGE_LENGTH
private static final int MIN_MESSAGE_LENGTH- See Also:
-
MAX_MESSAGE_LENGTH
private static final int MAX_MESSAGE_LENGTH- See Also:
-
HANDSHAKE_FAKE_LENGTH
private static final int HANDSHAKE_FAKE_LENGTH- See Also:
-
SS
private static final byte SS- See Also:
-
payload_buffer
-
length_buffer
-
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
-
protocol_bytes_last_read
private int protocol_bytes_last_read -
data_bytes_last_read
private int data_bytes_last_read -
progress_id
private int progress_id -
progress
private int[] progress
-
-
Constructor Details
-
BTMessageDecoder
public BTMessageDecoder()
-
-
Method Details
-
performStreamDecode
Description copied from interface:MessageStreamDecoderDecode message stream from the given transport.- Specified by:
performStreamDecodein interfaceMessageStreamDecoder- Parameters:
transport- to decode frommax_bytes- to decode/read from the stream- Returns:
- number of bytes decoded
- Throws:
IOException- on decoding error
-
getCurrentMessageProgress
public int[] getCurrentMessageProgress()Description copied from interface:MessageStreamDecoderGet the details of the current message that is being received (read from the transport).- Specified by:
getCurrentMessageProgressin interfaceMessageStreamDecoder- Returns:
- [ size, done ] or null
-
removeDecodedMessages
Description copied from interface:MessageStreamDecoderGet the messages decoded from the transport, if any, from the last decode op.- Specified by:
removeDecodedMessagesin interfaceMessageStreamDecoder- Returns:
- decoded messages, or null if no new complete messages were decoded
-
getProtocolBytesDecoded
public int getProtocolBytesDecoded()Description copied from interface:MessageStreamDecoderGet the number of protocol (overhead) bytes decoded from the transport, from the last decode op.- Specified by:
getProtocolBytesDecodedin interfaceMessageStreamDecoder- Returns:
- number of protocol bytes received
-
getDataBytesDecoded
public int getDataBytesDecoded()Description copied from interface:MessageStreamDecoderGet the number of (piece) data bytes decoded from the transport, from the last decode op.- Specified by:
getDataBytesDecodedin interfaceMessageStreamDecoder- Returns:
- number of data bytes received
-
destroy
Description copied from interface:MessageStreamDecoderDestroy this decoder, i.e. perform cleanup.- Specified by:
destroyin interfaceMessageStreamDecoder- Returns:
- any bytes already-read and still remaining within the decoder
-
preReadProcess
private long preReadProcess(long allowed) -
postReadProcess
- Throws:
IOException
-
pauseDecoding
public void pauseDecoding()Description copied from interface:MessageStreamDecoderPause message decoding.- Specified by:
pauseDecodingin interfaceMessageStreamDecoder
-
resumeDecoding
public void resumeDecoding()Description copied from interface:MessageStreamDecoderResume message decoding.- Specified by:
resumeDecodingin interfaceMessageStreamDecoder
-
createMessage
- Throws:
MessageException
-