/** * {@inheritDoc} * * @see * org.jboss.netty.channel.SimpleChannelUpstreamHandler#messageReceived(org.jboss.netty.channel.ChannelHandlerContext, * org.jboss.netty.channel.MessageEvent) */ public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) { final SocketAddress remote = e.getRemoteAddress(); ChannelBuffer buff = (ChannelBuffer) e.getMessage(); if (buff.equals(BYE_BUFF)) { e.getChannel() .write(BYE_MSG, remote) .addListener( new ChannelFutureListener() { @Override public void operationComplete(ChannelFuture future) throws Exception { future.getChannel().close(); } }); return; } e.getChannel() .write(e.getMessage(), remote) .addListener( new ChannelFutureListener() { @Override public void operationComplete(ChannelFuture future) throws Exception { if (future.isSuccess()) { logger.info(" S:OK"); } else { logger.info(" S:FAILED"); } } }); }