package com.github.nettybook.ch0; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelInboundHandlerAdapter; import io.netty.util.internal.logging.InternalLogger; import io.netty.util.internal.logging.InternalLoggerFactory; /** * Handles a server-side channel. */ public class FirstHandler extends ChannelInboundHandlerAdapter { private static final InternalLogger logger = InternalLoggerFactory .getInstance(FirstHandler.class); @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { logger.info("First handler"); ctx.fireChannelRead(msg); } @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { // Close the connection when an exception is raised. cause.printStackTrace(); ctx.close(); } }