com.iteaj.iot.client.codec.SimpleChannelInboundClient 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.ClientComponent;
import com.iteaj.iot.client.ClientConnectProperties;
import com.iteaj.iot.client.TcpSocketClient;
import com.iteaj.iot.client.component.TcpClientComponent;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandler;
import io.netty.channel.SimpleChannelInboundHandler;
public class SimpleChannelInboundClient extends TcpSocketClient {
public SimpleChannelInboundClient(TcpClientComponent clientComponent, ClientConnectProperties config) {
super(clientComponent, config);
}
/**
* @see SimpleChannelInboundHandler
* @return
*/
@Override
protected ChannelInboundHandler createProtocolDecoder() {
// autoRelease 必须是 false
return new SimpleChannelInboundHandler(false) {
@Override
protected void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) throws Exception {
SocketMessage socketMessage = SimpleChannelInboundClient.this.getClientComponent().proxy(ctx, msg);
if(socketMessage != null) {
ctx.fireChannelRead(socketMessage);
}
}
};
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy