public final class InterestedHandler extends UniqueMessageHandler<Interested>
| Constructor and Description |
|---|
InterestedHandler() |
| Modifier and Type | Method and Description |
|---|---|
int |
doDecode(DecodingContext context,
ByteBufferView buffer)
Decode the payload of a message (excluding message prefix -- see
StandardBittorrentProtocol.MESSAGE_PREFIX_SIZE)
and place it into the provided context. |
boolean |
doEncode(EncodingContext context,
Interested message,
ByteBuffer buffer)
Encode the payload of a message (excluding message prefix -- see
StandardBittorrentProtocol.MESSAGE_PREFIX_SIZE)
and write it into the provided buffer. |
getSupportedTypes, readMessageTypedecode, encodepublic int doDecode(DecodingContext context, ByteBufferView buffer)
BaseMessageHandlerStandardBittorrentProtocol.MESSAGE_PREFIX_SIZE)
and place it into the provided context.doDecode in class BaseMessageHandler<Interested>context - The context to place the decoded message into.buffer - Buffer to decode from. Buffer.remaining() is set
to the declared length of the message.
Message payload starts precisely at buffer's Buffer.position().public boolean doEncode(EncodingContext context, Interested message, ByteBuffer buffer)
BaseMessageHandlerStandardBittorrentProtocol.MESSAGE_PREFIX_SIZE)
and write it into the provided buffer.doEncode in class BaseMessageHandler<Interested>context - Encoding contextbuffer - Byte buffer to write to.
Encoded message should be placed into the buffer starting with its current position.
This method should check if the buffer has sufficient space available, and return false
if it's not the case.
After this method returns, the buffer's Buffer.position() is used
to calculate the size of message's payload, which is then specified in the message's prefix.Copyright © 2016–2021. All rights reserved.