@Override public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { Session session = new Session(ctx.getChannel()); netHandler.onConnected(session); ctx.setAttachment(session); }
@Override public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception { netHandler.exceptionCaught((Session) ctx.getAttachment(), e.getCause()); }
@Override public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { NetMessage message = (NetMessage) e.getMessage(); message.setSession((Session) ctx.getAttachment()); netHandler.messageReceived(message); }
@Override public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { netHandler.onClosed((Session) ctx.getAttachment()); }