public NetServer createNetServer(NetServerOptions options) { return new NetServerImpl(this, options); }
public synchronized void close() { close(null); }
@Override public NetSocketStream handler(Handler<NetSocket> handler) { connectHandler(handler); return this; }
if (!listening) { if (done != null) { executeCloseDone(context, done, null); executeCloseDone(context, done, null); actualServer.actualClose(context, done);
applyConnectionOptions(socketAddress.path() != null, bootstrap); this.actualPort = shared.actualPort(); VertxMetrics metrics = vertx.metricsSPI(); this.metrics = metrics != null ? metrics.createNetServerMetrics(options, new SocketAddressImpl(id.port, id.host)) : null;
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); }); }
private void actualClose(ContextInternal closeContext, Handler<AsyncResult<Void>> done) { if (id != null) { vertx.sharedNetServers().remove(id); } ContextInternal currCon = vertx.getContext(); for (NetSocketImpl sock : socketMap.values()) { sock.close(); } // Sanity check if (vertx.getContext() != currCon) { throw new IllegalStateException("Context was changed"); } ChannelGroupFuture fut = serverChannelGroup.close(); fut.addListener(cg -> { if (metrics != null) { metrics.close(); } executeCloseDone(closeContext, done, fut.cause()); }); }
@Override protected void initChannel(Channel ch) throws Exception { if (!accept()) { ch.close(); return;
server.closeAll(serverCloseHandler);
if (!listening) { if (done != null) { executeCloseDone(context, done, null); executeCloseDone(context, done, null); actualServer.actualClose(context, done);
applyConnectionOptions(socketAddress.path() != null, bootstrap); this.actualPort = shared.actualPort(); VertxMetrics metrics = vertx.metricsSPI(); this.metrics = metrics != null ? metrics.createNetServerMetrics(options, new SocketAddressImpl(id.port, id.host)) : null;
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); }); }
private void actualClose(ContextInternal closeContext, Handler<AsyncResult<Void>> done) { if (id != null) { vertx.sharedNetServers().remove(id); } ContextInternal currCon = vertx.getContext(); for (NetSocketImpl sock : socketMap.values()) { sock.close(); } // Sanity check if (vertx.getContext() != currCon) { throw new IllegalStateException("Context was changed"); } ChannelGroupFuture fut = serverChannelGroup.close(); fut.addListener(cg -> { if (metrics != null) { metrics.close(); } executeCloseDone(closeContext, done, fut.cause()); }); }
@Override protected void initChannel(Channel ch) throws Exception { if (!accept()) { ch.close(); return;
server.closeAll(serverCloseHandler);
@Override protected void finalize() throws Throwable { // Make sure this gets cleaned up if there are no more references to it // so as not to leave connections and resources dangling until the system is shutdown // which could make the JVM run out of file handles. close(); super.finalize(); }
@Override public NetSocketStream handler(Handler<NetSocket> handler) { connectHandler(handler); return this; }
public NetServer createNetServer(NetServerOptions options) { return new NetServerImpl(this, options); }
public synchronized void close() { close(null); }
@Override protected void finalize() throws Throwable { // Make sure this gets cleaned up if there are no more references to it // so as not to leave connections and resources dangling until the system is shutdown // which could make the JVM run out of file handles. close(); super.finalize(); }