com.iteaj.iot.client.codec.DelimiterBasedFrameClient Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of iot-client Show documentation
Show all versions of iot-client Show documentation
基于netty的tcp, http, udp等协议的客户端
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