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

io.vertx.rxjava3.core.http.WebSocketBase 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.core.http;

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;

/**
 * Base WebSocket implementation.
 * 

* It implements both and so it can be used with * {@link io.vertx.rxjava3.core.streams.Pipe} to pipe data with flow control. * *

* NOTE: This class has been automatically generated from the {@link io.vertx.core.http.WebSocketBase original} non RX-ified interface using Vert.x codegen. */ @RxGen(io.vertx.core.http.WebSocketBase.class) public interface WebSocketBase extends io.vertx.rxjava3.core.streams.ReadStream, io.vertx.rxjava3.core.streams.WriteStream { io.vertx.core.http.WebSocketBase getDelegate(); /** * Pause this stream and return a to transfer the elements of this stream to a destination . *

* The stream will be resumed when the pipe will be wired to a WriteStream. * @return a pipe */ public io.vertx.rxjava3.core.streams.Pipe pipe(); /** * Pipe this ReadStream to the WriteStream. *

* Elements emitted by this stream will be written to the write stream until this stream ends or fails. *

* Once this stream has ended or failed, the write stream will be ended and the handler will be * called with the result. * @param dst the destination write stream * @return */ public io.reactivex.rxjava3.core.Completable pipeTo(io.vertx.rxjava3.core.streams.WriteStream dst); /** * Pipe this ReadStream to the WriteStream. *

* Elements emitted by this stream will be written to the write stream until this stream ends or fails. *

* Once this stream has ended or failed, the write stream will be ended and the handler will be * called with the result. * @param dst the destination write stream * @return */ public io.reactivex.rxjava3.core.Completable rxPipeTo(io.vertx.rxjava3.core.streams.WriteStream dst); /** * Same as but with an handler called when the operation completes * @param data * @return */ public io.reactivex.rxjava3.core.Completable write(io.vertx.rxjava3.core.buffer.Buffer data); /** * Same as but with an handler called when the operation completes * @param data * @return */ public io.reactivex.rxjava3.core.Completable rxWrite(io.vertx.rxjava3.core.buffer.Buffer data); /** * Same as but with an handler called when the operation completes * @param data * @return */ public io.reactivex.rxjava3.core.Completable end(io.vertx.rxjava3.core.buffer.Buffer data); /** * Same as but with an handler called when the operation completes * @param data * @return */ public io.reactivex.rxjava3.core.Completable rxEnd(io.vertx.rxjava3.core.buffer.Buffer data); /** * This will return true if there are more bytes in the write queue than the value set using {@link io.vertx.rxjava3.core.http.WebSocketBase#setWriteQueueMaxSize} * @return true if write queue is full */ public boolean writeQueueFull(); public io.vertx.rxjava3.core.http.WebSocketBase exceptionHandler(io.vertx.core.Handler handler); public io.vertx.rxjava3.core.http.WebSocketBase handler(io.vertx.core.Handler handler); public io.vertx.rxjava3.core.http.WebSocketBase pause(); public io.vertx.rxjava3.core.http.WebSocketBase resume(); public io.vertx.rxjava3.core.http.WebSocketBase fetch(long amount); public io.vertx.rxjava3.core.http.WebSocketBase endHandler(io.vertx.core.Handler endHandler); public io.vertx.rxjava3.core.http.WebSocketBase setWriteQueueMaxSize(int maxSize); public io.vertx.rxjava3.core.http.WebSocketBase drainHandler(io.vertx.core.Handler handler); /** * When a WebSocket is created, it may register an event handler with the event bus - the ID of that * handler is given by this method. *

* By default, no handler is registered, the feature must be enabled via {@link io.vertx.core.http.WebSocketConnectOptions} or {@link io.vertx.core.http.HttpServerOptions}. *

* Given this ID, a different event loop can send a binary frame to that event handler using the event bus and * that buffer will be received by this instance in its own event loop and written to the underlying connection. This * allows you to write data to other WebSockets which are owned by different event loops. * @return the binary handler id */ public java.lang.String binaryHandlerID(); /** * When a WebSocket is created, it may register an event handler with the eventbus, the ID of that * handler is given by textHandlerID. *

* By default, no handler is registered, the feature must be enabled via {@link io.vertx.core.http.WebSocketConnectOptions} or {@link io.vertx.core.http.HttpServerOptions}. *

* Given this ID, a different event loop can send a text frame to that event handler using the event bus and * that buffer will be received by this instance in its own event loop and written to the underlying connection. This * allows you to write data to other WebSockets which are owned by different event loops. * @return the text handler id */ public java.lang.String textHandlerID(); /** * Returns the WebSocket sub protocol selected by the WebSocket handshake. *

* On the server, the value will be null when the handler receives the WebSocket callback as the * handshake will not be completed yet. * @return */ public java.lang.String subProtocol(); /** * Returns the close status code received from the remote endpoint or null when not yet received. * @return */ public java.lang.Short closeStatusCode(); /** * Returns the close reason message from the remote endpoint or null when not yet received. * @return */ public java.lang.String closeReason(); /** * Returns the HTTP headers when the WebSocket is first obtained in the handler. *

* The headers will be null on subsequent interactions. * @return the headers */ public io.vertx.rxjava3.core.MultiMap headers(); /** * Same as {@link io.vertx.rxjava3.core.http.WebSocketBase#writeFrame} but with an handler called when the operation completes * @param frame * @return */ public io.reactivex.rxjava3.core.Completable writeFrame(io.vertx.rxjava3.core.http.WebSocketFrame frame); /** * Same as {@link io.vertx.rxjava3.core.http.WebSocketBase#writeFrame} but with an handler called when the operation completes * @param frame * @return */ public io.reactivex.rxjava3.core.Completable rxWriteFrame(io.vertx.rxjava3.core.http.WebSocketFrame frame); /** * Same as {@link io.vertx.rxjava3.core.http.WebSocketBase#writeFinalTextFrame} but with an handler called when the operation completes * @param text * @return */ public io.reactivex.rxjava3.core.Completable writeFinalTextFrame(java.lang.String text); /** * Same as {@link io.vertx.rxjava3.core.http.WebSocketBase#writeFinalTextFrame} but with an handler called when the operation completes * @param text * @return */ public io.reactivex.rxjava3.core.Completable rxWriteFinalTextFrame(java.lang.String text); /** * Same as {@link io.vertx.rxjava3.core.http.WebSocketBase#writeFinalBinaryFrame} but with an handler called when the operation completes * @param data * @return */ public io.reactivex.rxjava3.core.Completable writeFinalBinaryFrame(io.vertx.rxjava3.core.buffer.Buffer data); /** * Same as {@link io.vertx.rxjava3.core.http.WebSocketBase#writeFinalBinaryFrame} but with an handler called when the operation completes * @param data * @return */ public io.reactivex.rxjava3.core.Completable rxWriteFinalBinaryFrame(io.vertx.rxjava3.core.buffer.Buffer data); /** * Same as {@link io.vertx.rxjava3.core.http.WebSocketBase#writeBinaryMessage} but with an handler called when the operation completes * @param data * @return */ public io.reactivex.rxjava3.core.Completable writeBinaryMessage(io.vertx.rxjava3.core.buffer.Buffer data); /** * Same as {@link io.vertx.rxjava3.core.http.WebSocketBase#writeBinaryMessage} but with an handler called when the operation completes * @param data * @return */ public io.reactivex.rxjava3.core.Completable rxWriteBinaryMessage(io.vertx.rxjava3.core.buffer.Buffer data); /** * Same as {@link io.vertx.rxjava3.core.http.WebSocketBase#writeTextMessage} but with an handler called when the operation completes * @param text * @return */ public io.reactivex.rxjava3.core.Completable writeTextMessage(java.lang.String text); /** * Same as {@link io.vertx.rxjava3.core.http.WebSocketBase#writeTextMessage} but with an handler called when the operation completes * @param text * @return */ public io.reactivex.rxjava3.core.Completable rxWriteTextMessage(java.lang.String text); /** * Writes a ping frame to the connection. This will be written in a single frame. Ping frames may be at most 125 bytes (octets). *

* This method should not be used to write application data and should only be used for implementing a keep alive or * to ensure the client is still responsive, see RFC 6455 Section section 5.5.2. *

* There is no handler for ping frames because RFC 6455 clearly * states that the only response to a ping frame is a pong frame with identical contents. * @param data the data to write, may be at most 125 bytes * @return a reference to this, so the API can be used fluently */ public io.reactivex.rxjava3.core.Completable writePing(io.vertx.rxjava3.core.buffer.Buffer data); /** * Writes a ping frame to the connection. This will be written in a single frame. Ping frames may be at most 125 bytes (octets). *

* This method should not be used to write application data and should only be used for implementing a keep alive or * to ensure the client is still responsive, see RFC 6455 Section section 5.5.2. *

* There is no handler for ping frames because RFC 6455 clearly * states that the only response to a ping frame is a pong frame with identical contents. * @param data the data to write, may be at most 125 bytes * @return a reference to this, so the API can be used fluently */ public io.reactivex.rxjava3.core.Completable rxWritePing(io.vertx.rxjava3.core.buffer.Buffer data); /** * Writes a pong frame to the connection. This will be written in a single frame. Pong frames may be at most 125 bytes (octets). *

* This method should not be used to write application data and should only be used for implementing a keep alive or * to ensure the client is still responsive, see RFC 6455 section 5.5.2. *

* There is no need to manually write a pong frame, as the server and client both handle responding to a ping from with a pong from * automatically and this is exposed to users. RFC 6455 section 5.5.3 states that pongs may be sent unsolicited in order * to implement a one way heartbeat. * @param data the data to write, may be at most 125 bytes * @return a reference to this, so the API can be used fluently */ public io.reactivex.rxjava3.core.Completable writePong(io.vertx.rxjava3.core.buffer.Buffer data); /** * Writes a pong frame to the connection. This will be written in a single frame. Pong frames may be at most 125 bytes (octets). *

* This method should not be used to write application data and should only be used for implementing a keep alive or * to ensure the client is still responsive, see RFC 6455 section 5.5.2. *

* There is no need to manually write a pong frame, as the server and client both handle responding to a ping from with a pong from * automatically and this is exposed to users. RFC 6455 section 5.5.3 states that pongs may be sent unsolicited in order * to implement a one way heartbeat. * @param data the data to write, may be at most 125 bytes * @return a reference to this, so the API can be used fluently */ public io.reactivex.rxjava3.core.Completable rxWritePong(io.vertx.rxjava3.core.buffer.Buffer data); /** * Set a close handler. This will be called when the WebSocket is closed. *

* After this callback, no more messages are expected. When the WebSocket received a close frame, the * {@link io.vertx.rxjava3.core.http.WebSocketBase#closeStatusCode} will return the status code and {@link io.vertx.rxjava3.core.http.WebSocketBase#closeReason} will return the reason. * @param handler the handler * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava3.core.http.WebSocketBase closeHandler(io.vertx.core.Handler handler); /** * Set a frame handler on the connection. This handler will be called when frames are read on the connection. * @param handler the handler * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava3.core.http.WebSocketBase frameHandler(io.vertx.core.Handler handler); /** * Set a text message handler on the connection. This handler will be called similar to the * {@link io.vertx.rxjava3.core.http.WebSocketBase#binaryMessageHandler}, but the buffer will be converted to a String first * @param handler the handler * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava3.core.http.WebSocketBase textMessageHandler(io.vertx.core.Handler handler); /** * Set a binary message handler on the connection. This handler serves a similar purpose to {@link io.vertx.rxjava3.core.http.WebSocketBase#handler} * except that if a message comes into the socket in multiple frames, the data from the frames will be aggregated * into a single buffer before calling the handler (using {@link io.vertx.rxjava3.core.http.WebSocketFrame#isFinal} to find the boundaries). * @param handler the handler * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava3.core.http.WebSocketBase binaryMessageHandler(io.vertx.core.Handler handler); /** * Set a pong frame handler on the connection. This handler will be invoked every time a pong frame is received * on the server, and can be used by both clients and servers since the RFC 6455 section 5.5.2 and section 5.5.3 do not * specify whether the client or server sends a ping. *

* Pong frames may be at most 125 bytes (octets). *

* There is no ping handler since ping frames should immediately be responded to with a pong frame with identical content *

* Pong frames may be received unsolicited. * @param handler the handler * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava3.core.http.WebSocketBase pongHandler(io.vertx.core.Handler handler); /** * * * Calls {@link io.vertx.rxjava3.core.http.WebSocketBase#close} * @return */ public io.reactivex.rxjava3.core.Completable end(); /** * * * Calls {@link io.vertx.rxjava3.core.http.WebSocketBase#close} * @return */ public io.reactivex.rxjava3.core.Completable rxEnd(); /** * Same as {@link io.vertx.rxjava3.core.http.WebSocketBase#close} but with an handler called when the operation completes * @return */ public io.reactivex.rxjava3.core.Completable close(); /** * Same as {@link io.vertx.rxjava3.core.http.WebSocketBase#close} but with an handler called when the operation completes * @return */ public io.reactivex.rxjava3.core.Completable rxClose(); /** * Same as {@link io.vertx.rxjava3.core.http.WebSocketBase#close} but with an handler called when the operation completes * @param statusCode * @return */ public io.reactivex.rxjava3.core.Completable close(short statusCode); /** * Same as {@link io.vertx.rxjava3.core.http.WebSocketBase#close} but with an handler called when the operation completes * @param statusCode * @return */ public io.reactivex.rxjava3.core.Completable rxClose(short statusCode); /** * Same as {@link io.vertx.rxjava3.core.http.WebSocketBase#close} but with an handler called when the operation completes * @param statusCode * @param reason * @return */ public io.reactivex.rxjava3.core.Completable close(short statusCode, java.lang.String reason); /** * Same as {@link io.vertx.rxjava3.core.http.WebSocketBase#close} but with an handler called when the operation completes * @param statusCode * @param reason * @return */ public io.reactivex.rxjava3.core.Completable rxClose(short statusCode, java.lang.String reason); /** * @return the remote address for this connection, possibly null (e.g a server bound on a domain socket). If useProxyProtocol is set to true, the address returned will be of the actual connecting client. */ public io.vertx.rxjava3.core.net.SocketAddress remoteAddress(); /** * @return the local address for this connection, possibly null (e.g a server bound on a domain socket) If useProxyProtocol is set to true, the address returned will be of the proxy. */ public io.vertx.rxjava3.core.net.SocketAddress localAddress(); /** * @return true if this {@link io.vertx.rxjava3.core.http.HttpConnection} is encrypted via SSL/TLS. */ public boolean isSsl(); /** * @return true if the WebSocket is closed */ public boolean isClosed(); public static WebSocketBase newInstance(io.vertx.core.http.WebSocketBase arg) { return arg != null ? new WebSocketBaseImpl(arg) : null; } } class WebSocketBaseImpl implements WebSocketBase { private final io.vertx.core.http.WebSocketBase delegate; public WebSocketBaseImpl(io.vertx.core.http.WebSocketBase delegate) { this.delegate = delegate; } public WebSocketBaseImpl(Object delegate) { this.delegate = (io.vertx.core.http.WebSocketBase)delegate; } public io.vertx.core.http.WebSocketBase getDelegate() { return delegate; } private io.reactivex.rxjava3.core.Observable observable; private io.reactivex.rxjava3.core.Flowable flowable; public synchronized io.reactivex.rxjava3.core.Observable toObservable() { if (observable == null) { Function conv = io.vertx.rxjava3.core.buffer.Buffer::newInstance; observable = ObservableHelper.toObservable(delegate, conv); } return observable; } public synchronized io.reactivex.rxjava3.core.Flowable toFlowable() { if (flowable == null) { Function conv = io.vertx.rxjava3.core.buffer.Buffer::newInstance; flowable = FlowableHelper.toFlowable(delegate, conv); } return flowable; } private WriteStreamObserver observer; private WriteStreamSubscriber subscriber; public synchronized WriteStreamObserver toObserver() { if (observer == null) { Function conv = io.vertx.rxjava3.core.buffer.Buffer::getDelegate; observer = RxHelper.toObserver(getDelegate(), conv); } return observer; } public synchronized WriteStreamSubscriber toSubscriber() { if (subscriber == null) { Function conv = io.vertx.rxjava3.core.buffer.Buffer::getDelegate; subscriber = RxHelper.toSubscriber(getDelegate(), conv); } return subscriber; } private static final TypeArg TYPE_ARG_0 = new TypeArg(o1 -> io.vertx.rxjava3.core.buffer.Buffer.newInstance((io.vertx.core.buffer.Buffer)o1), o1 -> o1.getDelegate()); /** * Pause this stream and return a to transfer the elements of this stream to a destination . *

* The stream will be resumed when the pipe will be wired to a WriteStream. * @return a pipe */ public io.vertx.rxjava3.core.streams.Pipe pipe() { io.vertx.rxjava3.core.streams.Pipe ret = io.vertx.rxjava3.core.streams.Pipe.newInstance((io.vertx.core.streams.Pipe)delegate.pipe(), TYPE_ARG_0); return ret; } /** * Pipe this ReadStream to the WriteStream. *

* Elements emitted by this stream will be written to the write stream until this stream ends or fails. *

* Once this stream has ended or failed, the write stream will be ended and the handler will be * called with the result. * @param dst the destination write stream * @return */ public io.reactivex.rxjava3.core.Completable pipeTo(io.vertx.rxjava3.core.streams.WriteStream dst) { io.reactivex.rxjava3.core.Completable ret = rxPipeTo(dst); ret = ret.cache(); ret.subscribe(io.vertx.rxjava3.CompletableHelper.nullObserver()); return ret; } /** * Pipe this ReadStream to the WriteStream. *

* Elements emitted by this stream will be written to the write stream until this stream ends or fails. *

* Once this stream has ended or failed, the write stream will be ended and the handler will be * called with the result. * @param dst the destination write stream * @return */ public io.reactivex.rxjava3.core.Completable rxPipeTo(io.vertx.rxjava3.core.streams.WriteStream dst) { return AsyncResultCompletable.toCompletable( handler -> { delegate.pipeTo(dst.getDelegate(), handler); }); } /** * Same as but with an handler called when the operation completes * @param data * @return */ public io.reactivex.rxjava3.core.Completable write(io.vertx.rxjava3.core.buffer.Buffer data) { io.reactivex.rxjava3.core.Completable ret = rxWrite(data); ret = ret.cache(); ret.subscribe(io.vertx.rxjava3.CompletableHelper.nullObserver()); return ret; } /** * Same as but with an handler called when the operation completes * @param data * @return */ public io.reactivex.rxjava3.core.Completable rxWrite(io.vertx.rxjava3.core.buffer.Buffer data) { return AsyncResultCompletable.toCompletable( handler -> { delegate.write(data.getDelegate(), handler); }); } /** * Same as but with an handler called when the operation completes * @param data * @return */ public io.reactivex.rxjava3.core.Completable end(io.vertx.rxjava3.core.buffer.Buffer data) { io.reactivex.rxjava3.core.Completable ret = rxEnd(data); ret = ret.cache(); ret.subscribe(io.vertx.rxjava3.CompletableHelper.nullObserver()); return ret; } /** * Same as but with an handler called when the operation completes * @param data * @return */ public io.reactivex.rxjava3.core.Completable rxEnd(io.vertx.rxjava3.core.buffer.Buffer data) { return AsyncResultCompletable.toCompletable( handler -> { delegate.end(data.getDelegate(), handler); }); } /** * This will return true if there are more bytes in the write queue than the value set using {@link io.vertx.rxjava3.core.http.WebSocketBase#setWriteQueueMaxSize} * @return true if write queue is full */ public boolean writeQueueFull() { boolean ret = delegate.writeQueueFull(); return ret; } public io.vertx.rxjava3.core.http.WebSocketBase exceptionHandler(io.vertx.core.Handler handler) { delegate.exceptionHandler(handler); return this; } public io.vertx.rxjava3.core.http.WebSocketBase handler(io.vertx.core.Handler handler) { delegate.handler(new io.vertx.lang.rx.DelegatingHandler<>(handler, event -> io.vertx.rxjava3.core.buffer.Buffer.newInstance((io.vertx.core.buffer.Buffer)event))); return this; } public io.vertx.rxjava3.core.http.WebSocketBase pause() { delegate.pause(); return this; } public io.vertx.rxjava3.core.http.WebSocketBase resume() { delegate.resume(); return this; } public io.vertx.rxjava3.core.http.WebSocketBase fetch(long amount) { delegate.fetch(amount); return this; } public io.vertx.rxjava3.core.http.WebSocketBase endHandler(io.vertx.core.Handler endHandler) { delegate.endHandler(endHandler); return this; } public io.vertx.rxjava3.core.http.WebSocketBase setWriteQueueMaxSize(int maxSize) { delegate.setWriteQueueMaxSize(maxSize); return this; } public io.vertx.rxjava3.core.http.WebSocketBase drainHandler(io.vertx.core.Handler handler) { delegate.drainHandler(handler); return this; } /** * When a WebSocket is created, it may register an event handler with the event bus - the ID of that * handler is given by this method. *

* By default, no handler is registered, the feature must be enabled via {@link io.vertx.core.http.WebSocketConnectOptions} or {@link io.vertx.core.http.HttpServerOptions}. *

* Given this ID, a different event loop can send a binary frame to that event handler using the event bus and * that buffer will be received by this instance in its own event loop and written to the underlying connection. This * allows you to write data to other WebSockets which are owned by different event loops. * @return the binary handler id */ public java.lang.String binaryHandlerID() { java.lang.String ret = delegate.binaryHandlerID(); return ret; } /** * When a WebSocket is created, it may register an event handler with the eventbus, the ID of that * handler is given by textHandlerID. *

* By default, no handler is registered, the feature must be enabled via {@link io.vertx.core.http.WebSocketConnectOptions} or {@link io.vertx.core.http.HttpServerOptions}. *

* Given this ID, a different event loop can send a text frame to that event handler using the event bus and * that buffer will be received by this instance in its own event loop and written to the underlying connection. This * allows you to write data to other WebSockets which are owned by different event loops. * @return the text handler id */ public java.lang.String textHandlerID() { java.lang.String ret = delegate.textHandlerID(); return ret; } /** * Returns the WebSocket sub protocol selected by the WebSocket handshake. *

* On the server, the value will be null when the handler receives the WebSocket callback as the * handshake will not be completed yet. * @return */ public java.lang.String subProtocol() { java.lang.String ret = delegate.subProtocol(); return ret; } /** * Returns the close status code received from the remote endpoint or null when not yet received. * @return */ public java.lang.Short closeStatusCode() { java.lang.Short ret = delegate.closeStatusCode(); return ret; } /** * Returns the close reason message from the remote endpoint or null when not yet received. * @return */ public java.lang.String closeReason() { java.lang.String ret = delegate.closeReason(); return ret; } /** * Returns the HTTP headers when the WebSocket is first obtained in the handler. *

* The headers will be null on subsequent interactions. * @return the headers */ public io.vertx.rxjava3.core.MultiMap headers() { io.vertx.rxjava3.core.MultiMap ret = io.vertx.rxjava3.core.MultiMap.newInstance((io.vertx.core.MultiMap)delegate.headers()); return ret; } /** * Same as {@link io.vertx.rxjava3.core.http.WebSocketBase#writeFrame} but with an handler called when the operation completes * @param frame * @return */ public io.reactivex.rxjava3.core.Completable writeFrame(io.vertx.rxjava3.core.http.WebSocketFrame frame) { io.reactivex.rxjava3.core.Completable ret = rxWriteFrame(frame); ret = ret.cache(); ret.subscribe(io.vertx.rxjava3.CompletableHelper.nullObserver()); return ret; } /** * Same as {@link io.vertx.rxjava3.core.http.WebSocketBase#writeFrame} but with an handler called when the operation completes * @param frame * @return */ public io.reactivex.rxjava3.core.Completable rxWriteFrame(io.vertx.rxjava3.core.http.WebSocketFrame frame) { return AsyncResultCompletable.toCompletable( handler -> { delegate.writeFrame(frame.getDelegate(), handler); }); } /** * Same as {@link io.vertx.rxjava3.core.http.WebSocketBase#writeFinalTextFrame} but with an handler called when the operation completes * @param text * @return */ public io.reactivex.rxjava3.core.Completable writeFinalTextFrame(java.lang.String text) { io.reactivex.rxjava3.core.Completable ret = rxWriteFinalTextFrame(text); ret = ret.cache(); ret.subscribe(io.vertx.rxjava3.CompletableHelper.nullObserver()); return ret; } /** * Same as {@link io.vertx.rxjava3.core.http.WebSocketBase#writeFinalTextFrame} but with an handler called when the operation completes * @param text * @return */ public io.reactivex.rxjava3.core.Completable rxWriteFinalTextFrame(java.lang.String text) { return AsyncResultCompletable.toCompletable( handler -> { delegate.writeFinalTextFrame(text, handler); }); } /** * Same as {@link io.vertx.rxjava3.core.http.WebSocketBase#writeFinalBinaryFrame} but with an handler called when the operation completes * @param data * @return */ public io.reactivex.rxjava3.core.Completable writeFinalBinaryFrame(io.vertx.rxjava3.core.buffer.Buffer data) { io.reactivex.rxjava3.core.Completable ret = rxWriteFinalBinaryFrame(data); ret = ret.cache(); ret.subscribe(io.vertx.rxjava3.CompletableHelper.nullObserver()); return ret; } /** * Same as {@link io.vertx.rxjava3.core.http.WebSocketBase#writeFinalBinaryFrame} but with an handler called when the operation completes * @param data * @return */ public io.reactivex.rxjava3.core.Completable rxWriteFinalBinaryFrame(io.vertx.rxjava3.core.buffer.Buffer data) { return AsyncResultCompletable.toCompletable( handler -> { delegate.writeFinalBinaryFrame(data.getDelegate(), handler); }); } /** * Same as {@link io.vertx.rxjava3.core.http.WebSocketBase#writeBinaryMessage} but with an handler called when the operation completes * @param data * @return */ public io.reactivex.rxjava3.core.Completable writeBinaryMessage(io.vertx.rxjava3.core.buffer.Buffer data) { io.reactivex.rxjava3.core.Completable ret = rxWriteBinaryMessage(data); ret = ret.cache(); ret.subscribe(io.vertx.rxjava3.CompletableHelper.nullObserver()); return ret; } /** * Same as {@link io.vertx.rxjava3.core.http.WebSocketBase#writeBinaryMessage} but with an handler called when the operation completes * @param data * @return */ public io.reactivex.rxjava3.core.Completable rxWriteBinaryMessage(io.vertx.rxjava3.core.buffer.Buffer data) { return AsyncResultCompletable.toCompletable( handler -> { delegate.writeBinaryMessage(data.getDelegate(), handler); }); } /** * Same as {@link io.vertx.rxjava3.core.http.WebSocketBase#writeTextMessage} but with an handler called when the operation completes * @param text * @return */ public io.reactivex.rxjava3.core.Completable writeTextMessage(java.lang.String text) { io.reactivex.rxjava3.core.Completable ret = rxWriteTextMessage(text); ret = ret.cache(); ret.subscribe(io.vertx.rxjava3.CompletableHelper.nullObserver()); return ret; } /** * Same as {@link io.vertx.rxjava3.core.http.WebSocketBase#writeTextMessage} but with an handler called when the operation completes * @param text * @return */ public io.reactivex.rxjava3.core.Completable rxWriteTextMessage(java.lang.String text) { return AsyncResultCompletable.toCompletable( handler -> { delegate.writeTextMessage(text, handler); }); } /** * Writes a ping frame to the connection. This will be written in a single frame. Ping frames may be at most 125 bytes (octets). *

* This method should not be used to write application data and should only be used for implementing a keep alive or * to ensure the client is still responsive, see RFC 6455 Section section 5.5.2. *

* There is no handler for ping frames because RFC 6455 clearly * states that the only response to a ping frame is a pong frame with identical contents. * @param data the data to write, may be at most 125 bytes * @return a reference to this, so the API can be used fluently */ public io.reactivex.rxjava3.core.Completable writePing(io.vertx.rxjava3.core.buffer.Buffer data) { io.reactivex.rxjava3.core.Completable ret = rxWritePing(data); ret = ret.cache(); ret.subscribe(io.vertx.rxjava3.CompletableHelper.nullObserver()); return ret; } /** * Writes a ping frame to the connection. This will be written in a single frame. Ping frames may be at most 125 bytes (octets). *

* This method should not be used to write application data and should only be used for implementing a keep alive or * to ensure the client is still responsive, see RFC 6455 Section section 5.5.2. *

* There is no handler for ping frames because RFC 6455 clearly * states that the only response to a ping frame is a pong frame with identical contents. * @param data the data to write, may be at most 125 bytes * @return a reference to this, so the API can be used fluently */ public io.reactivex.rxjava3.core.Completable rxWritePing(io.vertx.rxjava3.core.buffer.Buffer data) { return AsyncResultCompletable.toCompletable( handler -> { delegate.writePing(data.getDelegate(), handler); }); } /** * Writes a pong frame to the connection. This will be written in a single frame. Pong frames may be at most 125 bytes (octets). *

* This method should not be used to write application data and should only be used for implementing a keep alive or * to ensure the client is still responsive, see RFC 6455 section 5.5.2. *

* There is no need to manually write a pong frame, as the server and client both handle responding to a ping from with a pong from * automatically and this is exposed to users. RFC 6455 section 5.5.3 states that pongs may be sent unsolicited in order * to implement a one way heartbeat. * @param data the data to write, may be at most 125 bytes * @return a reference to this, so the API can be used fluently */ public io.reactivex.rxjava3.core.Completable writePong(io.vertx.rxjava3.core.buffer.Buffer data) { io.reactivex.rxjava3.core.Completable ret = rxWritePong(data); ret = ret.cache(); ret.subscribe(io.vertx.rxjava3.CompletableHelper.nullObserver()); return ret; } /** * Writes a pong frame to the connection. This will be written in a single frame. Pong frames may be at most 125 bytes (octets). *

* This method should not be used to write application data and should only be used for implementing a keep alive or * to ensure the client is still responsive, see RFC 6455 section 5.5.2. *

* There is no need to manually write a pong frame, as the server and client both handle responding to a ping from with a pong from * automatically and this is exposed to users. RFC 6455 section 5.5.3 states that pongs may be sent unsolicited in order * to implement a one way heartbeat. * @param data the data to write, may be at most 125 bytes * @return a reference to this, so the API can be used fluently */ public io.reactivex.rxjava3.core.Completable rxWritePong(io.vertx.rxjava3.core.buffer.Buffer data) { return AsyncResultCompletable.toCompletable( handler -> { delegate.writePong(data.getDelegate(), handler); }); } /** * Set a close handler. This will be called when the WebSocket is closed. *

* After this callback, no more messages are expected. When the WebSocket received a close frame, the * {@link io.vertx.rxjava3.core.http.WebSocketBase#closeStatusCode} will return the status code and {@link io.vertx.rxjava3.core.http.WebSocketBase#closeReason} will return the reason. * @param handler the handler * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava3.core.http.WebSocketBase closeHandler(io.vertx.core.Handler handler) { delegate.closeHandler(handler); return this; } /** * Set a frame handler on the connection. This handler will be called when frames are read on the connection. * @param handler the handler * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava3.core.http.WebSocketBase frameHandler(io.vertx.core.Handler handler) { delegate.frameHandler(new io.vertx.lang.rx.DelegatingHandler<>(handler, event -> io.vertx.rxjava3.core.http.WebSocketFrame.newInstance((io.vertx.core.http.WebSocketFrame)event))); return this; } /** * Set a text message handler on the connection. This handler will be called similar to the * {@link io.vertx.rxjava3.core.http.WebSocketBase#binaryMessageHandler}, but the buffer will be converted to a String first * @param handler the handler * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava3.core.http.WebSocketBase textMessageHandler(io.vertx.core.Handler handler) { delegate.textMessageHandler(handler); return this; } /** * Set a binary message handler on the connection. This handler serves a similar purpose to {@link io.vertx.rxjava3.core.http.WebSocketBase#handler} * except that if a message comes into the socket in multiple frames, the data from the frames will be aggregated * into a single buffer before calling the handler (using {@link io.vertx.rxjava3.core.http.WebSocketFrame#isFinal} to find the boundaries). * @param handler the handler * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava3.core.http.WebSocketBase binaryMessageHandler(io.vertx.core.Handler handler) { delegate.binaryMessageHandler(new io.vertx.lang.rx.DelegatingHandler<>(handler, event -> io.vertx.rxjava3.core.buffer.Buffer.newInstance((io.vertx.core.buffer.Buffer)event))); return this; } /** * Set a pong frame handler on the connection. This handler will be invoked every time a pong frame is received * on the server, and can be used by both clients and servers since the RFC 6455 section 5.5.2 and section 5.5.3 do not * specify whether the client or server sends a ping. *

* Pong frames may be at most 125 bytes (octets). *

* There is no ping handler since ping frames should immediately be responded to with a pong frame with identical content *

* Pong frames may be received unsolicited. * @param handler the handler * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava3.core.http.WebSocketBase pongHandler(io.vertx.core.Handler handler) { delegate.pongHandler(new io.vertx.lang.rx.DelegatingHandler<>(handler, event -> io.vertx.rxjava3.core.buffer.Buffer.newInstance((io.vertx.core.buffer.Buffer)event))); return this; } /** * * * Calls {@link io.vertx.rxjava3.core.http.WebSocketBase#close} * @return */ public io.reactivex.rxjava3.core.Completable end() { io.reactivex.rxjava3.core.Completable ret = rxEnd(); ret = ret.cache(); ret.subscribe(io.vertx.rxjava3.CompletableHelper.nullObserver()); return ret; } /** * * * Calls {@link io.vertx.rxjava3.core.http.WebSocketBase#close} * @return */ public io.reactivex.rxjava3.core.Completable rxEnd() { return AsyncResultCompletable.toCompletable( handler -> { delegate.end(handler); }); } /** * Same as {@link io.vertx.rxjava3.core.http.WebSocketBase#close} but with an handler called when the operation completes * @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; } /** * Same as {@link io.vertx.rxjava3.core.http.WebSocketBase#close} but with an handler called when the operation completes * @return */ public io.reactivex.rxjava3.core.Completable rxClose() { return AsyncResultCompletable.toCompletable( handler -> { delegate.close(handler); }); } /** * Same as {@link io.vertx.rxjava3.core.http.WebSocketBase#close} but with an handler called when the operation completes * @param statusCode * @return */ public io.reactivex.rxjava3.core.Completable close(short statusCode) { io.reactivex.rxjava3.core.Completable ret = rxClose(statusCode); ret = ret.cache(); ret.subscribe(io.vertx.rxjava3.CompletableHelper.nullObserver()); return ret; } /** * Same as {@link io.vertx.rxjava3.core.http.WebSocketBase#close} but with an handler called when the operation completes * @param statusCode * @return */ public io.reactivex.rxjava3.core.Completable rxClose(short statusCode) { return AsyncResultCompletable.toCompletable( handler -> { delegate.close(statusCode, handler); }); } /** * Same as {@link io.vertx.rxjava3.core.http.WebSocketBase#close} but with an handler called when the operation completes * @param statusCode * @param reason * @return */ public io.reactivex.rxjava3.core.Completable close(short statusCode, java.lang.String reason) { io.reactivex.rxjava3.core.Completable ret = rxClose(statusCode, reason); ret = ret.cache(); ret.subscribe(io.vertx.rxjava3.CompletableHelper.nullObserver()); return ret; } /** * Same as {@link io.vertx.rxjava3.core.http.WebSocketBase#close} but with an handler called when the operation completes * @param statusCode * @param reason * @return */ public io.reactivex.rxjava3.core.Completable rxClose(short statusCode, java.lang.String reason) { return AsyncResultCompletable.toCompletable( handler -> { delegate.close(statusCode, reason, handler); }); } /** * @return the remote address for this connection, possibly null (e.g a server bound on a domain socket). If useProxyProtocol is set to true, the address returned will be of the actual connecting client. */ public io.vertx.rxjava3.core.net.SocketAddress remoteAddress() { if (cached_0 != null) { return cached_0; } io.vertx.rxjava3.core.net.SocketAddress ret = io.vertx.rxjava3.core.net.SocketAddress.newInstance((io.vertx.core.net.SocketAddress)delegate.remoteAddress()); cached_0 = ret; return ret; } /** * @return the local address for this connection, possibly null (e.g a server bound on a domain socket) If useProxyProtocol is set to true, the address returned will be of the proxy. */ public io.vertx.rxjava3.core.net.SocketAddress localAddress() { if (cached_1 != null) { return cached_1; } io.vertx.rxjava3.core.net.SocketAddress ret = io.vertx.rxjava3.core.net.SocketAddress.newInstance((io.vertx.core.net.SocketAddress)delegate.localAddress()); cached_1 = ret; return ret; } /** * @return true if this {@link io.vertx.rxjava3.core.http.HttpConnection} is encrypted via SSL/TLS. */ public boolean isSsl() { boolean ret = delegate.isSsl(); return ret; } /** * @return true if the WebSocket is closed */ public boolean isClosed() { boolean ret = delegate.isClosed(); return ret; } /** * @return SSLSession associated with the underlying socket. Returns null if connection is not SSL. */ public javax.net.ssl.SSLSession sslSession() { javax.net.ssl.SSLSession ret = delegate.sslSession(); return ret; } private io.vertx.rxjava3.core.net.SocketAddress cached_0; private io.vertx.rxjava3.core.net.SocketAddress cached_1; }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy