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

com.iteaj.iot.client.codec.DelimiterBasedFrameClient Maven / Gradle / Ivy

The newest version!
package com.iteaj.iot.client.codec;

import com.iteaj.iot.SocketMessage;
import com.iteaj.iot.client.ClientConnectProperties;
import com.iteaj.iot.client.TcpSocketClient;
import com.iteaj.iot.client.component.TcpClientComponent;
import com.iteaj.iot.codec.adapter.DelimiterBasedFrameMessageDecoderAdapter;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandler;

public class DelimiterBasedFrameClient extends TcpSocketClient {

    private int maxFrameLength;
    private boolean stripDelimiter;
    private boolean failFast;
    private ByteBuf[] delimiter;

    public DelimiterBasedFrameClient(TcpClientComponent clientComponent, ClientConnectProperties config
            , int maxFrameLength, boolean stripDelimiter, boolean failFast, ByteBuf... delimiter) {
        super(clientComponent, config);
        this.failFast = failFast;
        this.delimiter = delimiter;
        this.maxFrameLength = maxFrameLength;
        this.stripDelimiter = stripDelimiter;
    }

    @Override
    protected ChannelInboundHandler createProtocolDecoder() {
        return new DelimiterBasedFrameMessageDecoderAdapter(this.getMaxFrameLength(), this.isStripDelimiter()
                , this.isFailFast(), this.getDelimiter());
    }

    public int getMaxFrameLength() {
        return maxFrameLength;
    }

    public boolean isStripDelimiter() {
        return stripDelimiter;
    }

    public boolean isFailFast() {
        return failFast;
    }

    public ByteBuf[] getDelimiter() {
        return delimiter;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy