wzy
2021-02-28 d3cdbf19b53e24a1417364b098f7b8f71f36a208
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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());
    }
}