package com.xcong.excoin.netty.client; import com.xcong.excoin.netty.common.ClientChannelManager; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelInboundHandlerAdapter; import lombok.extern.slf4j.Slf4j; /** * @author wzy * @email wangdoubleone@gmail.com * @date 2019-05-14 */ @Slf4j public class ClientChannelHandler extends ChannelInboundHandlerAdapter { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { log.error("",cause); } @Override public void channelActive(ChannelHandlerContext ctx) throws Exception { ClientChannelManager.addServerGroup(ctx.channel()); } @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { log.info("消息收到"); } @Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { ClientChannelManager.removeServerGroup(ctx.channel()); } }