bt.protocol.handler.ChokeHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bt-core Show documentation
Show all versions of bt-core Show documentation
BitTorrent Client Library (Core)
package bt.protocol.handler;
import bt.protocol.Choke;
import bt.protocol.DecodingContext;
import bt.protocol.EncodingContext;
import java.nio.ByteBuffer;
import static bt.protocol.Protocols.verifyPayloadHasLength;
public final class ChokeHandler extends UniqueMessageHandler {
public ChokeHandler() {
super(Choke.class);
}
@Override
public int doDecode(DecodingContext context, ByteBuffer buffer) {
verifyPayloadHasLength(Choke.class, 0, buffer.remaining());
context.setMessage(Choke.instance());
return 0;
}
@Override
public boolean doEncode(EncodingContext context, Choke message, ByteBuffer buffer) {
return true;
}
}