All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jeesuite.filesystem.sdk.fdfs.exchange.ReplierDecoder Maven / Gradle / Ivy

There is a newer version: 1.3.6
Show newest version
/**
 *
 */
package com.jeesuite.filesystem.sdk.fdfs.exchange;

import io.netty.buffer.ByteBuf;

import java.util.concurrent.CompletableFuture;

/**
 * 默认接收器实现
 *
 * @author liulongbiao
 */
public class ReplierDecoder extends ReplierSupport {

    private Decoder decoder;

    public ReplierDecoder(Decoder decoder) {
        this.decoder = decoder;
    }

    protected long expectLength() {
        return decoder.expectLength();
    }

    protected void readContent(ByteBuf in, CompletableFuture promise) {

        if (in.readableBytes() < length) {
            return;
        }

        ByteBuf buf = in.readSlice((int) length);
        T result = decoder.decode(buf);
        promise.complete(result);
        atHead = true;
    }

    @Override
    public String toString() {
        return "ReplierDecoder{" +
                "decoder=" + decoder +
                '}';
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy