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

io.vertx.reactivex.core.http.WebSocketBase Maven / Gradle / Ivy

/*
 * 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.reactivex.core.http;

import io.vertx.reactivex.RxHelper;
import io.vertx.reactivex.ObservableHelper;
import io.vertx.reactivex.FlowableHelper;
import io.vertx.reactivex.impl.AsyncResultMaybe;
import io.vertx.reactivex.impl.AsyncResultSingle;
import io.vertx.reactivex.impl.AsyncResultCompletable;
import io.vertx.reactivex.WriteStreamObserver;
import io.vertx.reactivex.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.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;

/**
 * Base WebSocket implementation.
 * 

* It implements both and so it can be used with * {@link io.vertx.reactivex.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.reactivex.core.streams.ReadStream, io.vertx.reactivex.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.reactivex.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. * @param dst the destination write stream * @return a future notified when the write stream will be ended with the outcome */ public io.vertx.core.Future pipeTo(io.vertx.reactivex.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. * @param dst the destination write stream * @return a future notified when the write stream will be ended with the outcome */ public io.reactivex.Completable rxPipeTo(io.vertx.reactivex.core.streams.WriteStream dst); /** * Write some data to the stream. * *

The data is usually put on an internal write queue, and the write actually happens * asynchronously. To avoid running out of memory by putting too much on the write queue, * check the {@link io.vertx.reactivex.core.streams.WriteStream#writeQueueFull} method before writing. This is done automatically if * using a . * *

When the data is moved from the queue to the actual medium, the returned * will be completed with the write result, e.g the future is succeeded * when a server HTTP response buffer is written to the socket and failed if the remote * client has closed the socket while the data was still pending for write. * @param data the data to write * @return a future completed with the write result */ public io.vertx.core.Future write(io.vertx.core.buffer.Buffer data); /** * Write some data to the stream. * *

The data is usually put on an internal write queue, and the write actually happens * asynchronously. To avoid running out of memory by putting too much on the write queue, * check the {@link io.vertx.reactivex.core.streams.WriteStream#writeQueueFull} method before writing. This is done automatically if * using a . * *

When the data is moved from the queue to the actual medium, the returned * will be completed with the write result, e.g the future is succeeded * when a server HTTP response buffer is written to the socket and failed if the remote * client has closed the socket while the data was still pending for write. * @param data the data to write * @return a future completed with the write result */ public io.reactivex.Completable rxWrite(io.vertx.core.buffer.Buffer data); /** * Same as {@link io.vertx.reactivex.core.http.WebSocketBase#end} but writes some data to the stream before ending. * @param data the data to write * @return a future completed with the result */ public io.vertx.core.Future end(io.vertx.core.buffer.Buffer data); /** * Same as {@link io.vertx.reactivex.core.http.WebSocketBase#end} but writes some data to the stream before ending. * @param data the data to write * @return a future completed with the result */ public io.reactivex.Completable rxEnd(io.vertx.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.reactivex.core.http.WebSocketBase#setWriteQueueMaxSize} * @return true if write queue is full */ public boolean writeQueueFull(); public io.vertx.reactivex.core.http.WebSocketBase exceptionHandler(io.vertx.core.Handler handler); public io.vertx.reactivex.core.http.WebSocketBase handler(io.vertx.core.Handler handler); public io.vertx.reactivex.core.http.WebSocketBase pause(); public io.vertx.reactivex.core.http.WebSocketBase resume(); public io.vertx.reactivex.core.http.WebSocketBase fetch(long amount); public io.vertx.reactivex.core.http.WebSocketBase endHandler(io.vertx.core.Handler endHandler); public io.vertx.reactivex.core.http.WebSocketBase setWriteQueueMaxSize(int maxSize); public io.vertx.reactivex.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. * @return the headers */ public io.vertx.core.MultiMap headers(); /** * Write a WebSocket frame to the connection * @param frame the frame to write * @return a future completed with the result */ public io.vertx.core.Future writeFrame(io.vertx.core.http.WebSocketFrame frame); /** * Write a WebSocket frame to the connection * @param frame the frame to write * @return a future completed with the result */ public io.reactivex.Completable rxWriteFrame(io.vertx.core.http.WebSocketFrame frame); /** * Write a final WebSocket text frame to the connection * @param text The text to write * @return a future completed with the result */ public io.vertx.core.Future writeFinalTextFrame(java.lang.String text); /** * Write a final WebSocket text frame to the connection * @param text The text to write * @return a future completed with the result */ public io.reactivex.Completable rxWriteFinalTextFrame(java.lang.String text); /** * Write a final WebSocket binary frame to the connection * @param data The data to write * @return a future completed with the result */ public io.vertx.core.Future writeFinalBinaryFrame(io.vertx.core.buffer.Buffer data); /** * Write a final WebSocket binary frame to the connection * @param data The data to write * @return a future completed with the result */ public io.reactivex.Completable rxWriteFinalBinaryFrame(io.vertx.core.buffer.Buffer data); /** * Writes a (potentially large) piece of binary data to the connection. This data might be written as multiple frames * if it exceeds the maximum WebSocket frame size. * @param data the data to write * @return a future completed with the result */ public io.vertx.core.Future writeBinaryMessage(io.vertx.core.buffer.Buffer data); /** * Writes a (potentially large) piece of binary data to the connection. This data might be written as multiple frames * if it exceeds the maximum WebSocket frame size. * @param data the data to write * @return a future completed with the result */ public io.reactivex.Completable rxWriteBinaryMessage(io.vertx.core.buffer.Buffer data); /** * Writes a (potentially large) piece of text data to the connection. This data might be written as multiple frames * if it exceeds the maximum WebSocket frame size. * @param text the data to write * @return a future completed with the result */ public io.vertx.core.Future writeTextMessage(java.lang.String text); /** * Writes a (potentially large) piece of text data to the connection. This data might be written as multiple frames * if it exceeds the maximum WebSocket frame size. * @param text the data to write * @return a future completed with the result */ public io.reactivex.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 future notified when the ping frame has been successfully written */ public io.vertx.core.Future writePing(io.vertx.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 future notified when the ping frame has been successfully written */ public io.reactivex.Completable rxWritePing(io.vertx.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 future notified when the pong frame has been successfully written */ public io.vertx.core.Future writePong(io.vertx.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 future notified when the pong frame has been successfully written */ public io.reactivex.Completable rxWritePong(io.vertx.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.reactivex.core.http.WebSocketBase#closeStatusCode} will return the status code and {@link io.vertx.reactivex.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.reactivex.core.http.WebSocketBase closeHandler(io.vertx.core.Handler handler); /** * Set a handler notified when the WebSocket is shutdown: the client or server will close the connection * within a certain amount of time. This gives the opportunity to the handler to close the WebSocket gracefully before * the WebSocket is forcefully closed. * @param handler the handler notified with the remaining shutdown * @return a reference to this, so the API can be used fluently */ public io.vertx.reactivex.core.http.WebSocketBase shutdownHandler(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.reactivex.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.reactivex.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.reactivex.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.reactivex.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.core.http.WebSocketFrame} to find the boundaries). * @param handler the handler * @return a reference to this, so the API can be used fluently */ public io.vertx.reactivex.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.reactivex.core.http.WebSocketBase pongHandler(io.vertx.core.Handler handler); /** * * * Calls {@link io.vertx.reactivex.core.http.WebSocketBase#close} * @return */ public io.vertx.core.Future end(); /** * * * Calls {@link io.vertx.reactivex.core.http.WebSocketBase#close} * @return */ public io.reactivex.Completable rxEnd(); /** * Close the WebSocket sending the default close frame. *

* No more messages can be sent. * @return a future completed with the result */ public io.vertx.core.Future close(); /** * Close the WebSocket sending the default close frame. *

* No more messages can be sent. * @return a future completed with the result */ public io.reactivex.Completable rxClose(); /** * Close the WebSocket sending a close frame with specified status code. You can give a look at various close payloads * here: RFC6455 section 7.4.1 *

* No more messages can be sent. * @param statusCode the status code * @return a future completed with the result */ public io.vertx.core.Future close(short statusCode); /** * Close the WebSocket sending a close frame with specified status code. You can give a look at various close payloads * here: RFC6455 section 7.4.1 *

* No more messages can be sent. * @param statusCode the status code * @return a future completed with the result */ public io.reactivex.Completable rxClose(short statusCode); /** * Close sending a close frame with specified status code and reason. You can give a look at various close payloads * here: RFC6455 section 7.4.1 *

* No more messages can be sent. * @param statusCode the status code * @param reason reason of closure * @return a future completed with the result */ public io.vertx.core.Future close(short statusCode, java.lang.String reason); /** * Close sending a close frame with specified status code and reason. You can give a look at various close payloads * here: RFC6455 section 7.4.1 *

* No more messages can be sent. * @param statusCode the status code * @param reason reason of closure * @return a future completed with the result */ public io.reactivex.Completable rxClose(short statusCode, java.lang.String reason); /** * Like {@link io.vertx.reactivex.core.http.WebSocketBase#shutdown} with a 30 seconds timeout, the status code 1000 a null reason. * @return */ public io.vertx.core.Future shutdown(); /** * Like {@link io.vertx.reactivex.core.http.WebSocketBase#shutdown} with a 30 seconds timeout, the status code 1000 a null reason. * @return */ public io.reactivex.Completable rxShutdown(); /** * Like {@link io.vertx.reactivex.core.http.WebSocketBase#shutdown} with a 30 seconds timeout and a null reason. * @param statusCode * @return */ public io.vertx.core.Future shutdown(short statusCode); /** * Like {@link io.vertx.reactivex.core.http.WebSocketBase#shutdown} with a 30 seconds timeout and a null reason. * @param statusCode * @return */ public io.reactivex.Completable rxShutdown(short statusCode); /** * Like {@link io.vertx.reactivex.core.http.WebSocketBase#shutdown} with a 30 seconds timeout. * @param statusCode * @param reason * @return */ public io.vertx.core.Future shutdown(short statusCode, java.lang.String reason); /** * Like {@link io.vertx.reactivex.core.http.WebSocketBase#shutdown} with a 30 seconds timeout. * @param statusCode * @param reason * @return */ public io.reactivex.Completable rxShutdown(short statusCode, java.lang.String reason); /** * Calls {@link io.vertx.reactivex.core.http.WebSocketBase#shutdown} with the status code 1000 and a null reason. * @param timeout * @param unit * @return */ public io.vertx.core.Future shutdown(long timeout, java.util.concurrent.TimeUnit unit); /** * Calls {@link io.vertx.reactivex.core.http.WebSocketBase#shutdown} with the status code 1000 and a null reason. * @param timeout * @param unit * @return */ public io.reactivex.Completable rxShutdown(long timeout, java.util.concurrent.TimeUnit unit); /** * Calls {@link io.vertx.reactivex.core.http.WebSocketBase#shutdown} with a null reason. * @param timeout * @param unit * @param statusCode * @return */ public io.vertx.core.Future shutdown(long timeout, java.util.concurrent.TimeUnit unit, short statusCode); /** * Calls {@link io.vertx.reactivex.core.http.WebSocketBase#shutdown} with a null reason. * @param timeout * @param unit * @param statusCode * @return */ public io.reactivex.Completable rxShutdown(long timeout, java.util.concurrent.TimeUnit unit, short statusCode); /** * Initiate a graceful WebSocket shutdown, the shutdown handler is notified and shall close the WebSocket, otherwise * after a timeout the WebSocket will be closed. *

* The WebSocket is closed with specified status code and reason. You can give a look at various close payloads * here: RFC6455 section 7.4.1 * @param timeout the amount of time after which all resources are forcibly closed * @param unit the of the timeout * @param statusCode the status code * @param reason reason of closure * @return a future completed when shutdown has completed */ public io.vertx.core.Future shutdown(long timeout, java.util.concurrent.TimeUnit unit, short statusCode, java.lang.String reason); /** * Initiate a graceful WebSocket shutdown, the shutdown handler is notified and shall close the WebSocket, otherwise * after a timeout the WebSocket will be closed. *

* The WebSocket is closed with specified status code and reason. You can give a look at various close payloads * here: RFC6455 section 7.4.1 * @param timeout the amount of time after which all resources are forcibly closed * @param unit the of the timeout * @param statusCode the status code * @param reason reason of closure * @return a future completed when shutdown has completed */ public io.reactivex.Completable rxShutdown(long timeout, java.util.concurrent.TimeUnit unit, 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.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.core.net.SocketAddress localAddress(); /** * @return true if this {@link io.vertx.reactivex.core.http.HttpConnection} is encrypted via SSL/TLS. */ public boolean isSsl(); /** * @return true if the WebSocket cannot be used to send message anymore */ 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.Observable observable; private io.reactivex.Flowable flowable; public synchronized io.reactivex.Observable toObservable() { if (observable == null) { observable = ObservableHelper.toObservable(this.getDelegate()); } return observable; } public synchronized io.reactivex.Flowable toFlowable() { if (flowable == null) { flowable = FlowableHelper.toFlowable(this.getDelegate()); } return flowable; } private WriteStreamObserver observer; private WriteStreamSubscriber subscriber; public synchronized WriteStreamObserver toObserver() { if (observer == null) { observer = RxHelper.toObserver(getDelegate()); } return observer; } public synchronized WriteStreamSubscriber toSubscriber() { if (subscriber == null) { subscriber = RxHelper.toSubscriber(getDelegate()); } return subscriber; } /** * 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.reactivex.core.streams.Pipe pipe() { io.vertx.reactivex.core.streams.Pipe ret = io.vertx.reactivex.core.streams.Pipe.newInstance((io.vertx.core.streams.Pipe)delegate.pipe(), TypeArg.unknown()); 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. * @param dst the destination write stream * @return a future notified when the write stream will be ended with the outcome */ public io.vertx.core.Future pipeTo(io.vertx.reactivex.core.streams.WriteStream dst) { io.vertx.core.Future ret = delegate.pipeTo(dst.getDelegate()).map(val -> val); 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. * @param dst the destination write stream * @return a future notified when the write stream will be ended with the outcome */ public io.reactivex.Completable rxPipeTo(io.vertx.reactivex.core.streams.WriteStream dst) { return AsyncResultCompletable.toCompletable($handler -> { this.pipeTo(dst).onComplete($handler); }); } /** * Write some data to the stream. * *

The data is usually put on an internal write queue, and the write actually happens * asynchronously. To avoid running out of memory by putting too much on the write queue, * check the {@link io.vertx.reactivex.core.streams.WriteStream#writeQueueFull} method before writing. This is done automatically if * using a . * *

When the data is moved from the queue to the actual medium, the returned * will be completed with the write result, e.g the future is succeeded * when a server HTTP response buffer is written to the socket and failed if the remote * client has closed the socket while the data was still pending for write. * @param data the data to write * @return a future completed with the write result */ public io.vertx.core.Future write(io.vertx.core.buffer.Buffer data) { io.vertx.core.Future ret = delegate.write(data).map(val -> val); return ret; } /** * Write some data to the stream. * *

The data is usually put on an internal write queue, and the write actually happens * asynchronously. To avoid running out of memory by putting too much on the write queue, * check the {@link io.vertx.reactivex.core.streams.WriteStream#writeQueueFull} method before writing. This is done automatically if * using a . * *

When the data is moved from the queue to the actual medium, the returned * will be completed with the write result, e.g the future is succeeded * when a server HTTP response buffer is written to the socket and failed if the remote * client has closed the socket while the data was still pending for write. * @param data the data to write * @return a future completed with the write result */ public io.reactivex.Completable rxWrite(io.vertx.core.buffer.Buffer data) { return AsyncResultCompletable.toCompletable($handler -> { this.write(data).onComplete($handler); }); } /** * Same as {@link io.vertx.reactivex.core.http.WebSocketBase#end} but writes some data to the stream before ending. * @param data the data to write * @return a future completed with the result */ public io.vertx.core.Future end(io.vertx.core.buffer.Buffer data) { io.vertx.core.Future ret = delegate.end(data).map(val -> val); return ret; } /** * Same as {@link io.vertx.reactivex.core.http.WebSocketBase#end} but writes some data to the stream before ending. * @param data the data to write * @return a future completed with the result */ public io.reactivex.Completable rxEnd(io.vertx.core.buffer.Buffer data) { return AsyncResultCompletable.toCompletable($handler -> { this.end(data).onComplete($handler); }); } /** * This will return true if there are more bytes in the write queue than the value set using {@link io.vertx.reactivex.core.http.WebSocketBase#setWriteQueueMaxSize} * @return true if write queue is full */ public boolean writeQueueFull() { boolean ret = delegate.writeQueueFull(); return ret; } public io.vertx.reactivex.core.http.WebSocketBase exceptionHandler(io.vertx.core.Handler handler) { delegate.exceptionHandler(handler); return this; } public io.vertx.reactivex.core.http.WebSocketBase handler(io.vertx.core.Handler handler) { delegate.handler(handler); return this; } public io.vertx.reactivex.core.http.WebSocketBase pause() { delegate.pause(); return this; } public io.vertx.reactivex.core.http.WebSocketBase resume() { delegate.resume(); return this; } public io.vertx.reactivex.core.http.WebSocketBase fetch(long amount) { delegate.fetch(amount); return this; } public io.vertx.reactivex.core.http.WebSocketBase endHandler(io.vertx.core.Handler endHandler) { delegate.endHandler(endHandler); return this; } public io.vertx.reactivex.core.http.WebSocketBase setWriteQueueMaxSize(int maxSize) { delegate.setWriteQueueMaxSize(maxSize); return this; } public io.vertx.reactivex.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. * @return the headers */ public io.vertx.core.MultiMap headers() { io.vertx.core.MultiMap ret = delegate.headers(); return ret; } /** * Write a WebSocket frame to the connection * @param frame the frame to write * @return a future completed with the result */ public io.vertx.core.Future writeFrame(io.vertx.core.http.WebSocketFrame frame) { io.vertx.core.Future ret = delegate.writeFrame(frame).map(val -> val); return ret; } /** * Write a WebSocket frame to the connection * @param frame the frame to write * @return a future completed with the result */ public io.reactivex.Completable rxWriteFrame(io.vertx.core.http.WebSocketFrame frame) { return AsyncResultCompletable.toCompletable($handler -> { this.writeFrame(frame).onComplete($handler); }); } /** * Write a final WebSocket text frame to the connection * @param text The text to write * @return a future completed with the result */ public io.vertx.core.Future writeFinalTextFrame(java.lang.String text) { io.vertx.core.Future ret = delegate.writeFinalTextFrame(text).map(val -> val); return ret; } /** * Write a final WebSocket text frame to the connection * @param text The text to write * @return a future completed with the result */ public io.reactivex.Completable rxWriteFinalTextFrame(java.lang.String text) { return AsyncResultCompletable.toCompletable($handler -> { this.writeFinalTextFrame(text).onComplete($handler); }); } /** * Write a final WebSocket binary frame to the connection * @param data The data to write * @return a future completed with the result */ public io.vertx.core.Future writeFinalBinaryFrame(io.vertx.core.buffer.Buffer data) { io.vertx.core.Future ret = delegate.writeFinalBinaryFrame(data).map(val -> val); return ret; } /** * Write a final WebSocket binary frame to the connection * @param data The data to write * @return a future completed with the result */ public io.reactivex.Completable rxWriteFinalBinaryFrame(io.vertx.core.buffer.Buffer data) { return AsyncResultCompletable.toCompletable($handler -> { this.writeFinalBinaryFrame(data).onComplete($handler); }); } /** * Writes a (potentially large) piece of binary data to the connection. This data might be written as multiple frames * if it exceeds the maximum WebSocket frame size. * @param data the data to write * @return a future completed with the result */ public io.vertx.core.Future writeBinaryMessage(io.vertx.core.buffer.Buffer data) { io.vertx.core.Future ret = delegate.writeBinaryMessage(data).map(val -> val); return ret; } /** * Writes a (potentially large) piece of binary data to the connection. This data might be written as multiple frames * if it exceeds the maximum WebSocket frame size. * @param data the data to write * @return a future completed with the result */ public io.reactivex.Completable rxWriteBinaryMessage(io.vertx.core.buffer.Buffer data) { return AsyncResultCompletable.toCompletable($handler -> { this.writeBinaryMessage(data).onComplete($handler); }); } /** * Writes a (potentially large) piece of text data to the connection. This data might be written as multiple frames * if it exceeds the maximum WebSocket frame size. * @param text the data to write * @return a future completed with the result */ public io.vertx.core.Future writeTextMessage(java.lang.String text) { io.vertx.core.Future ret = delegate.writeTextMessage(text).map(val -> val); return ret; } /** * Writes a (potentially large) piece of text data to the connection. This data might be written as multiple frames * if it exceeds the maximum WebSocket frame size. * @param text the data to write * @return a future completed with the result */ public io.reactivex.Completable rxWriteTextMessage(java.lang.String text) { return AsyncResultCompletable.toCompletable($handler -> { this.writeTextMessage(text).onComplete($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 future notified when the ping frame has been successfully written */ public io.vertx.core.Future writePing(io.vertx.core.buffer.Buffer data) { io.vertx.core.Future ret = delegate.writePing(data).map(val -> val); 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 future notified when the ping frame has been successfully written */ public io.reactivex.Completable rxWritePing(io.vertx.core.buffer.Buffer data) { return AsyncResultCompletable.toCompletable($handler -> { this.writePing(data).onComplete($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 future notified when the pong frame has been successfully written */ public io.vertx.core.Future writePong(io.vertx.core.buffer.Buffer data) { io.vertx.core.Future ret = delegate.writePong(data).map(val -> val); 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 future notified when the pong frame has been successfully written */ public io.reactivex.Completable rxWritePong(io.vertx.core.buffer.Buffer data) { return AsyncResultCompletable.toCompletable($handler -> { this.writePong(data).onComplete($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.reactivex.core.http.WebSocketBase#closeStatusCode} will return the status code and {@link io.vertx.reactivex.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.reactivex.core.http.WebSocketBase closeHandler(io.vertx.core.Handler handler) { delegate.closeHandler(handler); return this; } /** * Set a handler notified when the WebSocket is shutdown: the client or server will close the connection * within a certain amount of time. This gives the opportunity to the handler to close the WebSocket gracefully before * the WebSocket is forcefully closed. * @param handler the handler notified with the remaining shutdown * @return a reference to this, so the API can be used fluently */ public io.vertx.reactivex.core.http.WebSocketBase shutdownHandler(io.vertx.core.Handler handler) { delegate.shutdownHandler(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.reactivex.core.http.WebSocketBase frameHandler(io.vertx.core.Handler handler) { delegate.frameHandler(handler); return this; } /** * Set a text message handler on the connection. This handler will be called similar to the * {@link io.vertx.reactivex.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.reactivex.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.reactivex.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.core.http.WebSocketFrame} to find the boundaries). * @param handler the handler * @return a reference to this, so the API can be used fluently */ public io.vertx.reactivex.core.http.WebSocketBase binaryMessageHandler(io.vertx.core.Handler handler) { delegate.binaryMessageHandler(handler); 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.reactivex.core.http.WebSocketBase pongHandler(io.vertx.core.Handler handler) { delegate.pongHandler(handler); return this; } /** * * * Calls {@link io.vertx.reactivex.core.http.WebSocketBase#close} * @return */ public io.vertx.core.Future end() { io.vertx.core.Future ret = delegate.end().map(val -> val); return ret; } /** * * * Calls {@link io.vertx.reactivex.core.http.WebSocketBase#close} * @return */ public io.reactivex.Completable rxEnd() { return AsyncResultCompletable.toCompletable($handler -> { this.end().onComplete($handler); }); } /** * Close the WebSocket sending the default close frame. *

* No more messages can be sent. * @return a future completed with the result */ public io.vertx.core.Future close() { io.vertx.core.Future ret = delegate.close().map(val -> val); return ret; } /** * Close the WebSocket sending the default close frame. *

* No more messages can be sent. * @return a future completed with the result */ public io.reactivex.Completable rxClose() { return AsyncResultCompletable.toCompletable($handler -> { this.close().onComplete($handler); }); } /** * Close the WebSocket sending a close frame with specified status code. You can give a look at various close payloads * here: RFC6455 section 7.4.1 *

* No more messages can be sent. * @param statusCode the status code * @return a future completed with the result */ public io.vertx.core.Future close(short statusCode) { io.vertx.core.Future ret = delegate.close(statusCode).map(val -> val); return ret; } /** * Close the WebSocket sending a close frame with specified status code. You can give a look at various close payloads * here: RFC6455 section 7.4.1 *

* No more messages can be sent. * @param statusCode the status code * @return a future completed with the result */ public io.reactivex.Completable rxClose(short statusCode) { return AsyncResultCompletable.toCompletable($handler -> { this.close(statusCode).onComplete($handler); }); } /** * Close sending a close frame with specified status code and reason. You can give a look at various close payloads * here: RFC6455 section 7.4.1 *

* No more messages can be sent. * @param statusCode the status code * @param reason reason of closure * @return a future completed with the result */ public io.vertx.core.Future close(short statusCode, java.lang.String reason) { io.vertx.core.Future ret = delegate.close(statusCode, reason).map(val -> val); return ret; } /** * Close sending a close frame with specified status code and reason. You can give a look at various close payloads * here: RFC6455 section 7.4.1 *

* No more messages can be sent. * @param statusCode the status code * @param reason reason of closure * @return a future completed with the result */ public io.reactivex.Completable rxClose(short statusCode, java.lang.String reason) { return AsyncResultCompletable.toCompletable($handler -> { this.close(statusCode, reason).onComplete($handler); }); } /** * Like {@link io.vertx.reactivex.core.http.WebSocketBase#shutdown} with a 30 seconds timeout, the status code 1000 a null reason. * @return */ public io.vertx.core.Future shutdown() { io.vertx.core.Future ret = delegate.shutdown().map(val -> val); return ret; } /** * Like {@link io.vertx.reactivex.core.http.WebSocketBase#shutdown} with a 30 seconds timeout, the status code 1000 a null reason. * @return */ public io.reactivex.Completable rxShutdown() { return AsyncResultCompletable.toCompletable($handler -> { this.shutdown().onComplete($handler); }); } /** * Like {@link io.vertx.reactivex.core.http.WebSocketBase#shutdown} with a 30 seconds timeout and a null reason. * @param statusCode * @return */ public io.vertx.core.Future shutdown(short statusCode) { io.vertx.core.Future ret = delegate.shutdown(statusCode).map(val -> val); return ret; } /** * Like {@link io.vertx.reactivex.core.http.WebSocketBase#shutdown} with a 30 seconds timeout and a null reason. * @param statusCode * @return */ public io.reactivex.Completable rxShutdown(short statusCode) { return AsyncResultCompletable.toCompletable($handler -> { this.shutdown(statusCode).onComplete($handler); }); } /** * Like {@link io.vertx.reactivex.core.http.WebSocketBase#shutdown} with a 30 seconds timeout. * @param statusCode * @param reason * @return */ public io.vertx.core.Future shutdown(short statusCode, java.lang.String reason) { io.vertx.core.Future ret = delegate.shutdown(statusCode, reason).map(val -> val); return ret; } /** * Like {@link io.vertx.reactivex.core.http.WebSocketBase#shutdown} with a 30 seconds timeout. * @param statusCode * @param reason * @return */ public io.reactivex.Completable rxShutdown(short statusCode, java.lang.String reason) { return AsyncResultCompletable.toCompletable($handler -> { this.shutdown(statusCode, reason).onComplete($handler); }); } /** * Calls {@link io.vertx.reactivex.core.http.WebSocketBase#shutdown} with the status code 1000 and a null reason. * @param timeout * @param unit * @return */ 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; } /** * Calls {@link io.vertx.reactivex.core.http.WebSocketBase#shutdown} with the status code 1000 and a null reason. * @param timeout * @param unit * @return */ public io.reactivex.Completable rxShutdown(long timeout, java.util.concurrent.TimeUnit unit) { return AsyncResultCompletable.toCompletable($handler -> { this.shutdown(timeout, unit).onComplete($handler); }); } /** * Calls {@link io.vertx.reactivex.core.http.WebSocketBase#shutdown} with a null reason. * @param timeout * @param unit * @param statusCode * @return */ public io.vertx.core.Future shutdown(long timeout, java.util.concurrent.TimeUnit unit, short statusCode) { io.vertx.core.Future ret = delegate.shutdown(timeout, unit, statusCode).map(val -> val); return ret; } /** * Calls {@link io.vertx.reactivex.core.http.WebSocketBase#shutdown} with a null reason. * @param timeout * @param unit * @param statusCode * @return */ public io.reactivex.Completable rxShutdown(long timeout, java.util.concurrent.TimeUnit unit, short statusCode) { return AsyncResultCompletable.toCompletable($handler -> { this.shutdown(timeout, unit, statusCode).onComplete($handler); }); } /** * Initiate a graceful WebSocket shutdown, the shutdown handler is notified and shall close the WebSocket, otherwise * after a timeout the WebSocket will be closed. *

* The WebSocket is closed with specified status code and reason. You can give a look at various close payloads * here: RFC6455 section 7.4.1 * @param timeout the amount of time after which all resources are forcibly closed * @param unit the of the timeout * @param statusCode the status code * @param reason reason of closure * @return a future completed when shutdown has completed */ public io.vertx.core.Future shutdown(long timeout, java.util.concurrent.TimeUnit unit, short statusCode, java.lang.String reason) { io.vertx.core.Future ret = delegate.shutdown(timeout, unit, statusCode, reason).map(val -> val); return ret; } /** * Initiate a graceful WebSocket shutdown, the shutdown handler is notified and shall close the WebSocket, otherwise * after a timeout the WebSocket will be closed. *

* The WebSocket is closed with specified status code and reason. You can give a look at various close payloads * here: RFC6455 section 7.4.1 * @param timeout the amount of time after which all resources are forcibly closed * @param unit the of the timeout * @param statusCode the status code * @param reason reason of closure * @return a future completed when shutdown has completed */ public io.reactivex.Completable rxShutdown(long timeout, java.util.concurrent.TimeUnit unit, short statusCode, java.lang.String reason) { return AsyncResultCompletable.toCompletable($handler -> { this.shutdown(timeout, unit, statusCode, reason).onComplete($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.core.net.SocketAddress remoteAddress() { if (cached_0 != null) { return cached_0; } io.vertx.core.net.SocketAddress ret = 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.core.net.SocketAddress localAddress() { if (cached_1 != null) { return cached_1; } io.vertx.core.net.SocketAddress ret = delegate.localAddress(); cached_1 = ret; return ret; } /** * @return true if this {@link io.vertx.reactivex.core.http.HttpConnection} is encrypted via SSL/TLS. */ public boolean isSsl() { boolean ret = delegate.isSsl(); return ret; } /** * @return true if the WebSocket cannot be used to send message anymore */ 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.core.net.SocketAddress cached_0; private io.vertx.core.net.SocketAddress cached_1; }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy