Class AZMessageDecoder
java.lang.Object
com.biglybt.core.peermanager.messaging.azureus.AZMessageDecoder
- All Implemented Interfaces:
MessageStreamDecoder
Length-prefixed message decoding.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int
private final ByteBuffer[]
private boolean
private boolean
private boolean
private final DirectByteBuffer
private static final int
private int
private int
private final ArrayList
private static final int
private byte[]
private boolean
private DirectByteBuffer
private int
private int
private int[]
private int
private int
private boolean
private static final byte
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondestroy()
Destroy this decoder, i.e.int[]
Get the details of the current message that is being received (read from the transport).int
Get the number of (piece) data bytes decoded from the transport, from the last decode op.boolean
int
Get the number of protocol (overhead) bytes decoded from the transport, from the last decode op.void
Pause message decoding.int
performStreamDecode
(Transport transport, int max_bytes) Decode message stream from the given transport.private int
private int
preReadProcess
(int allowed) Message[]
Get the messages decoded from the transport, if any, from the last decode op.void
Resume message decoding.void
setMaximumMessageSize
(int max_bytes)
-
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:
-
SS
private static final byte SS- See Also:
-
payload_buffer
-
length_buffer
-
decode_array
-
reading_length_mode
private boolean reading_length_mode -
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 -
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 -
msg_id_bytes
private byte[] msg_id_bytes -
msg_id_read_complete
private boolean msg_id_read_complete -
last_read_made_progress
private boolean last_read_made_progress -
maximum_message_size
private int maximum_message_size
-
-
Constructor Details
-
AZMessageDecoder
public AZMessageDecoder()
-
-
Method Details
-
setMaximumMessageSize
public void setMaximumMessageSize(int max_bytes) -
performStreamDecode
Description copied from interface:MessageStreamDecoder
Decode message stream from the given transport.- Specified by:
performStreamDecode
in 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:MessageStreamDecoder
Get the details of the current message that is being received (read from the transport).- Specified by:
getCurrentMessageProgress
in interfaceMessageStreamDecoder
- Returns:
- [ size, done ] or null
-
removeDecodedMessages
Description copied from interface:MessageStreamDecoder
Get the messages decoded from the transport, if any, from the last decode op.- Specified by:
removeDecodedMessages
in interfaceMessageStreamDecoder
- 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 interfaceMessageStreamDecoder
- Returns:
- number of protocol bytes received
-
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 interfaceMessageStreamDecoder
- Returns:
- number of data bytes received
-
getLastReadMadeProgress
public boolean getLastReadMadeProgress() -
destroy
Description copied from interface:MessageStreamDecoder
Destroy this decoder, i.e. perform cleanup.- Specified by:
destroy
in interfaceMessageStreamDecoder
- Returns:
- any bytes already-read and still remaining within the decoder
-
preReadProcess
private int preReadProcess(int allowed) -
postReadProcess
- Throws:
IOException
-
pauseDecoding
public void pauseDecoding()Description copied from interface:MessageStreamDecoder
Pause message decoding.- Specified by:
pauseDecoding
in interfaceMessageStreamDecoder
-
resumeDecoding
public void resumeDecoding()Description copied from interface:MessageStreamDecoder
Resume message decoding.- Specified by:
resumeDecoding
in interfaceMessageStreamDecoder
-