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

io.vertx.rxjava3.ext.stomp.StompServer 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.rxjava3.ext.stomp;

import io.vertx.rxjava3.RxHelper;
import io.vertx.rxjava3.ObservableHelper;
import io.vertx.rxjava3.FlowableHelper;
import io.vertx.rxjava3.impl.AsyncResultMaybe;
import io.vertx.rxjava3.impl.AsyncResultSingle;
import io.vertx.rxjava3.impl.AsyncResultCompletable;
import io.vertx.rxjava3.WriteStreamObserver;
import io.vertx.rxjava3.WriteStreamSubscriber;
import java.util.Map;
import java.util.Set;
import java.util.List;
import java.util.Iterator;
import java.util.function.Function;
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;

/**
 * Defines a STOMP server. STOMP servers delegates to a {@link io.vertx.rxjava3.ext.stomp.StompServerHandler} that let customize the behavior of
 * the server. By default, it uses a handler compliant with the STOMP specification, but let you change anything.
 *
 * 

* NOTE: This class has been automatically generated from the {@link io.vertx.ext.stomp.StompServer original} non RX-ified interface using Vert.x codegen. */ @RxGen(io.vertx.ext.stomp.StompServer.class) public class StompServer { @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; StompServer that = (StompServer) o; return delegate.equals(that.delegate); } @Override public int hashCode() { return delegate.hashCode(); } public static final TypeArg __TYPE_ARG = new TypeArg<>( obj -> new StompServer((io.vertx.ext.stomp.StompServer) obj), StompServer::getDelegate ); private final io.vertx.ext.stomp.StompServer delegate; public StompServer(io.vertx.ext.stomp.StompServer delegate) { this.delegate = delegate; } public StompServer(Object delegate) { this.delegate = (io.vertx.ext.stomp.StompServer)delegate; } public io.vertx.ext.stomp.StompServer getDelegate() { return delegate; } private static final TypeArg TYPE_ARG_0 = new TypeArg(o1 -> io.vertx.rxjava3.core.http.ServerWebSocket.newInstance((io.vertx.core.http.ServerWebSocket)o1), o1 -> o1.getDelegate()); /** * Creates a {@link io.vertx.rxjava3.ext.stomp.StompServer} based on the default Stomp Server implementation. * @param vertx the vert.x instance to use * @param options the server options * @return the created {@link io.vertx.rxjava3.ext.stomp.StompServer} */ public static io.vertx.rxjava3.ext.stomp.StompServer create(io.vertx.rxjava3.core.Vertx vertx, io.vertx.ext.stomp.StompServerOptions options) { io.vertx.rxjava3.ext.stomp.StompServer ret = io.vertx.rxjava3.ext.stomp.StompServer.newInstance((io.vertx.ext.stomp.StompServer)io.vertx.ext.stomp.StompServer.create(vertx.getDelegate(), options)); return ret; } /** * Creates a {@link io.vertx.rxjava3.ext.stomp.StompServer} based on the default Stomp Server implementation. * @param vertx the vert.x instance to use * @param netServer the Net server used by the STOMP server * @return the created {@link io.vertx.rxjava3.ext.stomp.StompServer} */ public static io.vertx.rxjava3.ext.stomp.StompServer create(io.vertx.rxjava3.core.Vertx vertx, io.vertx.rxjava3.core.net.NetServer netServer) { io.vertx.rxjava3.ext.stomp.StompServer ret = io.vertx.rxjava3.ext.stomp.StompServer.newInstance((io.vertx.ext.stomp.StompServer)io.vertx.ext.stomp.StompServer.create(vertx.getDelegate(), netServer.getDelegate())); return ret; } /** * Creates a {@link io.vertx.rxjava3.ext.stomp.StompServer} based on the default Stomp Server implementation. * @param vertx the vert.x instance to use * @param net the Net server used by the STOMP server * @param options the server options * @return the created {@link io.vertx.rxjava3.ext.stomp.StompServer} */ public static io.vertx.rxjava3.ext.stomp.StompServer create(io.vertx.rxjava3.core.Vertx vertx, io.vertx.rxjava3.core.net.NetServer net, io.vertx.ext.stomp.StompServerOptions options) { io.vertx.rxjava3.ext.stomp.StompServer ret = io.vertx.rxjava3.ext.stomp.StompServer.newInstance((io.vertx.ext.stomp.StompServer)io.vertx.ext.stomp.StompServer.create(vertx.getDelegate(), net.getDelegate(), options)); return ret; } /** * Creates a {@link io.vertx.rxjava3.ext.stomp.StompServer} based on the default Stomp Server implementation, and use the default options. * @param vertx the vert.x instance to use * @return the created {@link io.vertx.rxjava3.ext.stomp.StompServer} */ public static io.vertx.rxjava3.ext.stomp.StompServer create(io.vertx.rxjava3.core.Vertx vertx) { io.vertx.rxjava3.ext.stomp.StompServer ret = io.vertx.rxjava3.ext.stomp.StompServer.newInstance((io.vertx.ext.stomp.StompServer)io.vertx.ext.stomp.StompServer.create(vertx.getDelegate())); return ret; } /** * Configures the {@link io.vertx.rxjava3.ext.stomp.StompServerHandler}. You must calls this method before calling the {@link io.vertx.rxjava3.ext.stomp.StompServer#listen} method. * @param handler the handler * @return the current {@link io.vertx.rxjava3.ext.stomp.StompServer} */ public io.vertx.rxjava3.ext.stomp.StompServer handler(io.vertx.rxjava3.ext.stomp.StompServerHandler handler) { delegate.handler(handler.getDelegate()); return this; } /** * Connects the STOMP server default port (61613) and network interface (0.0.0.0). Once the socket * it bounds calls the given handler with the result. The result may be a failure if the socket is already used. * @return the current {@link io.vertx.rxjava3.ext.stomp.StompServer} */ public io.reactivex.rxjava3.core.Single listen() { io.reactivex.rxjava3.core.Single ret = rxListen(); ret = ret.cache(); ret.subscribe(io.vertx.rxjava3.SingleHelper.nullObserver()); return ret; } /** * Connects the STOMP server default port (61613) and network interface (0.0.0.0). Once the socket * it bounds calls the given handler with the result. The result may be a failure if the socket is already used. * @return the current {@link io.vertx.rxjava3.ext.stomp.StompServer} */ public io.reactivex.rxjava3.core.Single rxListen() { return AsyncResultSingle.toSingle( handler -> { delegate.listen(new io.vertx.lang.rx.DelegatingHandler<>(handler, ar -> ar.map(event -> io.vertx.rxjava3.ext.stomp.StompServer.newInstance((io.vertx.ext.stomp.StompServer)event)))); }); } /** * Connects the STOMP server to the given port. This method use the default host (0.0.0.0). Once the socket * it bounds calls the given handler with the result. The result may be a failure if the socket is already used. * @param port the port * @return the current {@link io.vertx.rxjava3.ext.stomp.StompServer} */ public io.reactivex.rxjava3.core.Single listen(int port) { io.reactivex.rxjava3.core.Single ret = rxListen(port); ret = ret.cache(); ret.subscribe(io.vertx.rxjava3.SingleHelper.nullObserver()); return ret; } /** * Connects the STOMP server to the given port. This method use the default host (0.0.0.0). Once the socket * it bounds calls the given handler with the result. The result may be a failure if the socket is already used. * @param port the port * @return the current {@link io.vertx.rxjava3.ext.stomp.StompServer} */ public io.reactivex.rxjava3.core.Single rxListen(int port) { return AsyncResultSingle.toSingle( handler -> { delegate.listen(port, new io.vertx.lang.rx.DelegatingHandler<>(handler, ar -> ar.map(event -> io.vertx.rxjava3.ext.stomp.StompServer.newInstance((io.vertx.ext.stomp.StompServer)event)))); }); } /** * Connects the STOMP server to the given port / interface. Once the socket it bounds calls the given handler with * the result. The result may be a failure if the socket is already used. * @param port the port * @param host the host / interface * @return the current {@link io.vertx.rxjava3.ext.stomp.StompServer} */ public io.reactivex.rxjava3.core.Single listen(int port, java.lang.String host) { io.reactivex.rxjava3.core.Single ret = rxListen(port, host); ret = ret.cache(); ret.subscribe(io.vertx.rxjava3.SingleHelper.nullObserver()); return ret; } /** * Connects the STOMP server to the given port / interface. Once the socket it bounds calls the given handler with * the result. The result may be a failure if the socket is already used. * @param port the port * @param host the host / interface * @return the current {@link io.vertx.rxjava3.ext.stomp.StompServer} */ public io.reactivex.rxjava3.core.Single rxListen(int port, java.lang.String host) { return AsyncResultSingle.toSingle( handler -> { delegate.listen(port, host, new io.vertx.lang.rx.DelegatingHandler<>(handler, ar -> ar.map(event -> io.vertx.rxjava3.ext.stomp.StompServer.newInstance((io.vertx.ext.stomp.StompServer)event)))); }); } /** * Closes the server. * @return */ public io.reactivex.rxjava3.core.Completable close() { io.reactivex.rxjava3.core.Completable ret = rxClose(); ret = ret.cache(); ret.subscribe(io.vertx.rxjava3.CompletableHelper.nullObserver()); return ret; } /** * Closes the server. * @return */ public io.reactivex.rxjava3.core.Completable rxClose() { return AsyncResultCompletable.toCompletable( completionHandler -> { delegate.close(completionHandler); }); } /** * Checks whether or not the server is listening. * @return true if the server is listening, false otherwise */ public boolean isListening() { boolean ret = delegate.isListening(); return ret; } /** * Gets the port on which the server is listening. *

* This is useful if you bound the server specifying 0 as port number signifying an ephemeral port. * @return the port */ public int actualPort() { int ret = delegate.actualPort(); return ret; } /** * @return the server options */ public io.vertx.ext.stomp.StompServerOptions options() { io.vertx.ext.stomp.StompServerOptions ret = delegate.options(); return ret; } /** * @return the instance of vert.x used by the server. */ public io.vertx.rxjava3.core.Vertx vertx() { io.vertx.rxjava3.core.Vertx ret = io.vertx.rxjava3.core.Vertx.newInstance((io.vertx.core.Vertx)delegate.vertx()); return ret; } /** * @return the {@link io.vertx.rxjava3.ext.stomp.StompServerHandler} used by this server. */ public io.vertx.rxjava3.ext.stomp.StompServerHandler stompHandler() { io.vertx.rxjava3.ext.stomp.StompServerHandler ret = io.vertx.rxjava3.ext.stomp.StompServerHandler.newInstance((io.vertx.ext.stomp.StompServerHandler)delegate.stompHandler()); return ret; } /** * Gets the able to manage web socket connections. If the web socket bridge is disabled, it returns * null. * @return the handler that can be passed to {@link io.vertx.rxjava3.core.http.HttpServer#webSocketHandler}. */ public io.vertx.core.Handler webSocketHandler() { io.vertx.core.Handler ret = new Handler() { public void handle(io.vertx.rxjava3.core.http.ServerWebSocket event) { delegate.webSocketHandler().handle(event.getDelegate()); } }; return ret; } /** * Configures the handler that is invoked every time a frame is going to be written to the "wire". It lets you log * the frames, but also adapt the frame if needed. * @param handler the handler, must not be null * @return the current {@link io.vertx.rxjava3.ext.stomp.StompServer} */ public io.vertx.rxjava3.ext.stomp.StompServer writingFrameHandler(io.vertx.core.Handler handler) { delegate.writingFrameHandler(new io.vertx.lang.rx.DelegatingHandler<>(handler, event -> io.vertx.rxjava3.ext.stomp.ServerFrame.newInstance((io.vertx.ext.stomp.ServerFrame)event))); return this; } public static StompServer newInstance(io.vertx.ext.stomp.StompServer arg) { return arg != null ? new StompServer(arg) : null; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy