@Override public void exceptionCaught(ChannelHandlerContext chctx, final Throwable t) throws Exception { Channel ch = chctx.channel(); // Don't remove the connection at this point, or the handleClosed won't be called when channelInactive is called! C connection = getConnection(); if (connection != null) { context.executeFromIO(v -> { try { if (ch.isOpen()) { ch.close(); } } catch (Throwable ignore) { } connection.handleException(t); }); } else { ch.close(); } }
@Override public void channelWritabilityChanged(ChannelHandlerContext ctx) throws Exception { C conn = getConnection(); context.executeFromIO(v -> conn.handleInterestedOpsChanged()); }
private void connected(HandlerHolder<Handlers> handler, Channel ch) { NetServerImpl.this.initChannel(ch.pipeline()); VertxHandler<NetSocketImpl> nh = VertxHandler.<NetSocketImpl>create(handler.context, ctx -> new NetSocketImpl(vertx, ctx, handler.context, sslHelper, metrics)); nh.addHandler(conn -> socketMap.put(ch, conn)); nh.removeHandler(conn -> socketMap.remove(ch)); ch.pipeline().addLast("handler", nh); NetSocketImpl sock = nh.getConnection(); handler.context.executeFromIO(v -> { if (metrics != null) { sock.metric(metrics.connected(sock.remoteAddress(), sock.remoteName())); } sock.registerEventBusHandler(); handler.handler.connectionHandler.handle(sock); }); }
@Override public void exceptionCaught(ChannelHandlerContext chctx, final Throwable t) throws Exception { Channel ch = chctx.channel(); // Don't remove the connection at this point, or the handleClosed won't be called when channelInactive is called! C connection = getConnection(); if (connection != null) { context.executeFromIO(v -> { try { if (ch.isOpen()) { ch.close(); } } catch (Throwable ignore) { } connection.handleException(t); }); } else { ch.close(); } }
@Override public void channelWritabilityChanged(ChannelHandlerContext ctx) throws Exception { C conn = getConnection(); context.executeFromIO(v -> conn.handleInterestedOpsChanged()); }
private void connected(HandlerHolder<Handlers> handler, Channel ch) { NetServerImpl.this.initChannel(ch.pipeline()); VertxHandler<NetSocketImpl> nh = VertxHandler.<NetSocketImpl>create(handler.context, ctx -> new NetSocketImpl(vertx, ctx, handler.context, sslHelper, metrics)); nh.addHandler(conn -> socketMap.put(ch, conn)); nh.removeHandler(conn -> socketMap.remove(ch)); ch.pipeline().addLast("handler", nh); NetSocketImpl sock = nh.getConnection(); handler.context.executeFromIO(v -> { if (metrics != null) { sock.metric(metrics.connected(sock.remoteAddress(), sock.remoteName())); } sock.registerEventBusHandler(); handler.handler.connectionHandler.handle(sock); }); }