All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.vertx.rxjava.core.net.NetServer Maven / Gradle / Ivy

There is a newer version: 5.0.0.CR2
Show newest version
/*
 * Copyright 2014 Red Hat, Inc.
 *
 * Red Hat licenses this file to you under the Apache License, version 2.0
 * (the "License"); you may not use this file except in compliance with the
 * License.  You may obtain a copy of the License at:
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */

package io.vertx.rxjava.core.net;

import rx.Observable;
import rx.Single;
import io.vertx.rx.java.RxHelper;
import io.vertx.rx.java.WriteStreamSubscriber;
import io.vertx.rx.java.SingleOnSubscribeAdapter;
import java.util.Map;
import java.util.Set;
import java.util.List;
import java.util.Iterator;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import io.vertx.core.Handler;
import io.vertx.core.AsyncResult;
import io.vertx.core.json.JsonObject;
import io.vertx.core.json.JsonArray;
import io.vertx.lang.rx.RxGen;
import io.vertx.lang.rx.TypeArg;
import io.vertx.lang.rx.MappingIterator;

/**
 * Represents a TCP server
 *
 * 

* NOTE: This class has been automatically generated from the {@link io.vertx.core.net.NetServer original} non RX-ified interface using Vert.x codegen. */ @RxGen(io.vertx.core.net.NetServer.class) public class NetServer implements io.vertx.rxjava.core.metrics.Measured { @Override public String toString() { return delegate.toString(); } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; NetServer that = (NetServer) o; return delegate.equals(that.delegate); } @Override public int hashCode() { return delegate.hashCode(); } public static final TypeArg __TYPE_ARG = new TypeArg<>( obj -> new NetServer((io.vertx.core.net.NetServer) obj), NetServer::getDelegate ); private final io.vertx.core.net.NetServer delegate; public NetServer(io.vertx.core.net.NetServer delegate) { this.delegate = delegate; } public NetServer(Object delegate) { this.delegate = (io.vertx.core.net.NetServer)delegate; } public io.vertx.core.net.NetServer getDelegate() { return delegate; } private static final TypeArg TYPE_ARG_0 = new TypeArg(o1 -> io.vertx.rxjava.core.net.NetServer.newInstance((io.vertx.core.net.NetServer)o1), o1 -> o1.getDelegate()); private static final TypeArg TYPE_ARG_1 = new TypeArg(o1 -> io.vertx.rxjava.core.net.NetServer.newInstance((io.vertx.core.net.NetServer)o1), o1 -> o1.getDelegate()); private static final TypeArg TYPE_ARG_2 = new TypeArg(o1 -> io.vertx.rxjava.core.net.NetServer.newInstance((io.vertx.core.net.NetServer)o1), o1 -> o1.getDelegate()); private static final TypeArg TYPE_ARG_3 = new TypeArg(o1 -> io.vertx.rxjava.core.net.NetServer.newInstance((io.vertx.core.net.NetServer)o1), o1 -> o1.getDelegate()); /** * Whether the metrics are enabled for this measured object * @return true if metrics are enabled */ public boolean isMetricsEnabled() { boolean ret = delegate.isMetricsEnabled(); return ret; } /** * Supply a connect handler for this server. The server can only have at most one connect handler at any one time. * As the server accepts TCP or SSL connections it creates an instance of {@link io.vertx.rxjava.core.net.NetSocket} and passes it to the * connect handler. * @param handler * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.core.net.NetServer connectHandler(io.vertx.core.Handler handler) { io.vertx.rxjava.core.net.NetServer ret = io.vertx.rxjava.core.net.NetServer.newInstance((io.vertx.core.net.NetServer)delegate.connectHandler(new io.vertx.lang.rx.DelegatingHandler<>(handler, event -> io.vertx.rxjava.core.net.NetSocket.newInstance((io.vertx.core.net.NetSocket)event)))); return ret; } /** * Start listening on the port and host as configured in the {@link io.vertx.core.net.NetServerOptions} used when * creating the server. *

* The server may not be listening until some time after the call to listen has returned. * @return a future completed with the listen operation result */ public io.vertx.core.Future listen() { io.vertx.core.Future ret = delegate.listen().map(val -> io.vertx.rxjava.core.net.NetServer.newInstance((io.vertx.core.net.NetServer)val)); return ret; } /** * Start listening on the port and host as configured in the {@link io.vertx.core.net.NetServerOptions} used when * creating the server. *

* The server may not be listening until some time after the call to listen has returned. * @return a future completed with the listen operation result */ public rx.Single rxListen() { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { this.listen().onComplete(fut); })); } /** * Start listening on the specified port and host, ignoring port and host configured in the {@link io.vertx.core.net.NetServerOptions} used when * creating the server. *

* Port 0 can be specified meaning "choose an random port". *

* Host 0.0.0.0 can be specified meaning "listen on all available interfaces". *

* The server may not be listening until some time after the call to listen has returned. * @param port * @param host * @return a future completed with the listen operation result */ public io.vertx.core.Future listen(int port, java.lang.String host) { io.vertx.core.Future ret = delegate.listen(port, host).map(val -> io.vertx.rxjava.core.net.NetServer.newInstance((io.vertx.core.net.NetServer)val)); return ret; } /** * Start listening on the specified port and host, ignoring port and host configured in the {@link io.vertx.core.net.NetServerOptions} used when * creating the server. *

* Port 0 can be specified meaning "choose an random port". *

* Host 0.0.0.0 can be specified meaning "listen on all available interfaces". *

* The server may not be listening until some time after the call to listen has returned. * @param port * @param host * @return a future completed with the listen operation result */ public rx.Single rxListen(int port, java.lang.String host) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { this.listen(port, host).onComplete(fut); })); } /** * Start listening on the specified port and host "0.0.0.0", ignoring port and host configured in the * {@link io.vertx.core.net.NetServerOptions} used when creating the server. *

* Port 0 can be specified meaning "choose an random port". *

* The server may not be listening until some time after the call to listen has returned. * @param port * @return a future completed with the listen operation result */ public io.vertx.core.Future listen(int port) { io.vertx.core.Future ret = delegate.listen(port).map(val -> io.vertx.rxjava.core.net.NetServer.newInstance((io.vertx.core.net.NetServer)val)); return ret; } /** * Start listening on the specified port and host "0.0.0.0", ignoring port and host configured in the * {@link io.vertx.core.net.NetServerOptions} used when creating the server. *

* Port 0 can be specified meaning "choose an random port". *

* The server may not be listening until some time after the call to listen has returned. * @param port * @return a future completed with the listen operation result */ public rx.Single rxListen(int port) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { this.listen(port).onComplete(fut); })); } /** * Start listening on the specified local address, ignoring port and host configured in the {@link io.vertx.core.net.NetServerOptions} used when * creating the server. *

* The server may not be listening until some time after the call to listen has returned. * @param localAddress the local address to listen on * @return a future completed with the listen operation result */ public io.vertx.core.Future listen(io.vertx.core.net.SocketAddress localAddress) { io.vertx.core.Future ret = delegate.listen(localAddress).map(val -> io.vertx.rxjava.core.net.NetServer.newInstance((io.vertx.core.net.NetServer)val)); return ret; } /** * Start listening on the specified local address, ignoring port and host configured in the {@link io.vertx.core.net.NetServerOptions} used when * creating the server. *

* The server may not be listening until some time after the call to listen has returned. * @param localAddress the local address to listen on * @return a future completed with the listen operation result */ public rx.Single rxListen(io.vertx.core.net.SocketAddress localAddress) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { this.listen(localAddress).onComplete(fut); })); } /** * Close the server. This will close any currently open connections. The close may not complete until after this * method has returned. * @return a future completed with the listen operation result */ public io.vertx.core.Future close() { io.vertx.core.Future ret = delegate.close().map(val -> val); return ret; } /** * Close the server. This will close any currently open connections. The close may not complete until after this * method has returned. * @return a future completed with the listen operation result */ public rx.Single rxClose() { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { this.close().onComplete(fut); })); } /** * Shutdown with a 30 seconds timeout (shutdown(30, TimeUnit.SECONDS)). * @return a future completed when shutdown has completed */ public io.vertx.core.Future shutdown() { io.vertx.core.Future ret = delegate.shutdown().map(val -> val); return ret; } /** * Shutdown with a 30 seconds timeout (shutdown(30, TimeUnit.SECONDS)). * @return a future completed when shutdown has completed */ public rx.Single rxShutdown() { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { this.shutdown().onComplete(fut); })); } /** * Initiate the server shutdown sequence. *

* Connections are taken out of service and notified the close sequence has started through {@link io.vertx.rxjava.core.net.NetSocket#shutdownHandler}. * When all connections are closed the client is closed. When the timeout expires, all unclosed connections are immediately closed. * @param timeout the amount of time after which all resources are forcibly closed * @param unit the of the timeout * @return a future notified when the client is closed */ public io.vertx.core.Future shutdown(long timeout, java.util.concurrent.TimeUnit unit) { io.vertx.core.Future ret = delegate.shutdown(timeout, unit).map(val -> val); return ret; } /** * Initiate the server shutdown sequence. *

* Connections are taken out of service and notified the close sequence has started through {@link io.vertx.rxjava.core.net.NetSocket#shutdownHandler}. * When all connections are closed the client is closed. When the timeout expires, all unclosed connections are immediately closed. * @param timeout the amount of time after which all resources are forcibly closed * @param unit the of the timeout * @return a future notified when the client is closed */ public rx.Single rxShutdown(long timeout, java.util.concurrent.TimeUnit unit) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { this.shutdown(timeout, unit).onComplete(fut); })); } /** * The actual port the server is listening on. This is useful if you bound the server specifying 0 as port number * signifying an ephemeral port * @return the actual port the server is listening on. */ public int actualPort() { int ret = delegate.actualPort(); return ret; } /** *

Update the server with new SSL options, the update happens if the options object is valid and different * from the existing options object. * *

The boolean succeeded future result indicates whether the update occurred. * @param options the new SSL options * @return a future signaling the update success */ public io.vertx.core.Future updateSSLOptions(io.vertx.core.net.ServerSSLOptions options) { io.vertx.core.Future ret = delegate.updateSSLOptions(options).map(val -> val); return ret; } /** *

Update the server with new SSL options, the update happens if the options object is valid and different * from the existing options object. * *

The boolean succeeded future result indicates whether the update occurred. * @param options the new SSL options * @return a future signaling the update success */ public rx.Single rxUpdateSSLOptions(io.vertx.core.net.ServerSSLOptions options) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { this.updateSSLOptions(options).onComplete(fut); })); } /** *

Update the server with new SSL options, the update happens if the options object is valid and different * from the existing options object. * *

The options object is compared using its equals method against the existing options to prevent * an update when the objects are equals since loading options can be costly, this can happen for share TCP servers. * When object are equals, setting force to true forces the update. * *

The boolean succeeded future result indicates whether the update occurred. * @param options the new SSL options * @param force force the update when options are equals * @return a future signaling the update success */ public io.vertx.core.Future updateSSLOptions(io.vertx.core.net.ServerSSLOptions options, boolean force) { io.vertx.core.Future ret = delegate.updateSSLOptions(options, force).map(val -> val); return ret; } /** *

Update the server with new SSL options, the update happens if the options object is valid and different * from the existing options object. * *

The options object is compared using its equals method against the existing options to prevent * an update when the objects are equals since loading options can be costly, this can happen for share TCP servers. * When object are equals, setting force to true forces the update. * *

The boolean succeeded future result indicates whether the update occurred. * @param options the new SSL options * @param force force the update when options are equals * @return a future signaling the update success */ public rx.Single rxUpdateSSLOptions(io.vertx.core.net.ServerSSLOptions options, boolean force) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { this.updateSSLOptions(options, force).onComplete(fut); })); } /** * Update traffic shaping options options, the update happens if valid values are passed for traffic * shaping options. This update happens synchronously and at best effort for rate update to take effect immediately. * @param options the new traffic shaping options */ public void updateTrafficShapingOptions(io.vertx.core.net.TrafficShapingOptions options) { delegate.updateTrafficShapingOptions(options); } public static NetServer newInstance(io.vertx.core.net.NetServer arg) { return arg != null ? new NetServer(arg) : null; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy