1234567891011121314151617181920212223 |
- package com.persagy.ztkencryptdecodedata;
- import io.netty.channel.ChannelHandlerContext;
- import io.netty.channel.SimpleChannelInboundHandler;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- public class TcpServerHandler extends SimpleChannelInboundHandler<Object> {
- private static Logger logger = LoggerFactory.getLogger(TcpServerHandler.class);
- @Override
- protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
- ctx.channel().writeAndFlush("server收到消息:" + msg);
- }
- @Override
- public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
- logger.warn("exceptionCaught!", cause);
- ctx.close();
- }
- }
|