package com.xcong.excoin.netty.handler;
|
|
import com.xcong.excoin.netty.common.ServerChannelManager;
|
import io.netty.channel.ChannelHandler;
|
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelInboundHandlerAdapter;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.stereotype.Component;
|
|
/**
|
* @author wzy
|
* @email wangdoubleone@gmail.com
|
* @date 2019-05-06
|
*/
|
@Slf4j
|
@Component
|
@ChannelHandler.Sharable
|
public class TcpServerHandler extends ChannelInboundHandlerAdapter {
|
|
@Override
|
public void channelActive(ChannelHandlerContext ctx) {
|
log.info("[tcp客户端连入服务器]");
|
ServerChannelManager.addTcpChannel(ctx.channel());
|
}
|
|
@Override
|
public void channelInactive(ChannelHandlerContext ctx) {
|
log.info("[tcp客户端断开服务器]");
|
ServerChannelManager.removeTcpChannel(ctx.channel());
|
}
|
|
@Override
|
public void channelRead(ChannelHandlerContext ctx, Object msg) {
|
}
|
|
@Override
|
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
|
super.channelReadComplete(ctx);
|
}
|
|
@Override
|
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
|
super.userEventTriggered(ctx, evt);
|
}
|
|
@Override
|
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
|
}
|
}
|