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 SecondHandler extends ChannelInboundHandlerAdapter { private static final InternalLogger logger = InternalLoggerFactory .getInstance(SecondHandler.class); @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { logger.info("Second handler"); ctx.writeAndFlush(msg); } @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { // Close the connection when an exception is raised. cause.printStackTrace(); ctx.close(); } }