@Override public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e) { final NioSocketChannel ch = (NioSocketChannel) e.getChannel(); final NetSocket sock = socketMap.remove(ch); if (sock != null) { VertxInternal.instance.executeOnContext( sock.getContextID(), new Runnable() { public void run() { sock.handleClosed(); } }); } }
@Override public void channelInterestChanged(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { final NioSocketChannel ch = (NioSocketChannel) e.getChannel(); final NetSocket sock = socketMap.get(ch); ChannelState state = e.getState(); if (state == ChannelState.INTEREST_OPS) { VertxInternal.instance.executeOnContext( sock.getContextID(), new Runnable() { public void run() { sock.handleInterestedOpsChanged(); } }); } }
@Override public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) { final NioSocketChannel ch = (NioSocketChannel) e.getChannel(); final NetSocket sock = socketMap.get(ch); ch.close(); final Throwable t = e.getCause(); if (sock != null && t instanceof Exception) { VertxInternal.instance.executeOnContext( sock.getContextID(), new Runnable() { public void run() { sock.handleException((Exception) t); } }); } else { t.printStackTrace(); } }