io.vertx.rxjava.core.http.ServerWebSocket 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.rxjava.core.http;
import rx.Observable;
import rx.Single;
import io.vertx.rx.java.RxHelper;
import io.vertx.rx.java.WriteStreamSubscriber;
import io.vertx.rx.java.SingleOnSubscribeAdapter;
import java.util.Map;
import java.util.Set;
import java.util.List;
import java.util.Iterator;
import java.util.function.Function;
import java.util.stream.Collectors;
import io.vertx.core.Handler;
import io.vertx.core.AsyncResult;
import io.vertx.core.json.JsonObject;
import io.vertx.core.json.JsonArray;
import io.vertx.lang.rx.RxGen;
import io.vertx.lang.rx.TypeArg;
import io.vertx.lang.rx.MappingIterator;
/**
* Represents a server side WebSocket.
*
* Instances of this class are passed into a {@link io.vertx.rxjava.core.http.HttpServer#webSocketHandler} or provided
* when a WebSocket handshake is manually {@link io.vertx.rxjava.core.http.HttpServerRequest#upgrade}ed.
*
*
* NOTE: This class has been automatically generated from the {@link io.vertx.core.http.ServerWebSocket original} non RX-ified interface using Vert.x codegen.
*/
@RxGen(io.vertx.core.http.ServerWebSocket.class)
public class ServerWebSocket implements io.vertx.rxjava.core.http.WebSocketBase {
@Override
public String toString() {
return delegate.toString();
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ServerWebSocket that = (ServerWebSocket) o;
return delegate.equals(that.delegate);
}
@Override
public int hashCode() {
return delegate.hashCode();
}
public static final TypeArg __TYPE_ARG = new TypeArg<>( obj -> new ServerWebSocket((io.vertx.core.http.ServerWebSocket) obj),
ServerWebSocket::getDelegate
);
private final io.vertx.core.http.ServerWebSocket delegate;
public ServerWebSocket(io.vertx.core.http.ServerWebSocket delegate) {
this.delegate = delegate;
}
public ServerWebSocket(Object delegate) {
this.delegate = (io.vertx.core.http.ServerWebSocket)delegate;
}
public io.vertx.core.http.ServerWebSocket getDelegate() {
return delegate;
}
private Observable observable;
public synchronized Observable toObservable() {
if (observable == null) {
Function conv = io.vertx.rxjava.core.buffer.Buffer::newInstance;
observable = RxHelper.toObservable(delegate, conv);
}
return observable;
}
private WriteStreamSubscriber subscriber;
public synchronized WriteStreamSubscriber toSubscriber() {
if (subscriber == null) {
Function conv = io.vertx.rxjava.core.buffer.Buffer::getDelegate;
subscriber = RxHelper.toSubscriber(getDelegate(), conv);
}
return subscriber;
}
private static final TypeArg TYPE_ARG_0 = new TypeArg(o1 -> io.vertx.rxjava.core.buffer.Buffer.newInstance((io.vertx.core.buffer.Buffer)o1), o1 -> o1.getDelegate());
/**
* Same as {@link io.vertx.rxjava.core.http.WebSocketBase#end} but writes some data to the stream before ending.
* @param data the data to write
*/
public void end(io.vertx.rxjava.core.buffer.Buffer data) {
delegate.end(data.getDelegate());
}
/**
* Same as but with an handler
called when the operation completes
* @param data
* @param handler
*/
public void end(io.vertx.rxjava.core.buffer.Buffer data, Handler> handler) {
delegate.end(data.getDelegate(), handler);
}
/**
* Same as but with an handler
called when the operation completes
* @param data
* @return
* @deprecated use {@link #rxEnd} instead
*/
@Deprecated()
public Observable endObservable(io.vertx.rxjava.core.buffer.Buffer data) {
io.vertx.rx.java.ObservableFuture handler = io.vertx.rx.java.RxHelper.observableFuture();
end(data, handler.toHandler());
return handler;
}
/**
* Same as but with an handler
called when the operation completes
* @param data
* @return
*/
public Single rxEnd(io.vertx.rxjava.core.buffer.Buffer data) {
return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> {
end(data, fut);
}));
}
/**
* This will return true
if there are more bytes in the write queue than the value set using {@link io.vertx.rxjava.core.http.ServerWebSocket#setWriteQueueMaxSize}
* @return true if write queue is full
*/
public boolean writeQueueFull() {
boolean ret = delegate.writeQueueFull();
return ret;
}
/**
* 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.rxjava.core.streams.Pipe pipe() {
io.vertx.rxjava.core.streams.Pipe ret = io.vertx.rxjava.core.streams.Pipe.newInstance((io.vertx.core.streams.Pipe)delegate.pipe(), TYPE_ARG_0);
return ret;
}
/**
* Like {@link io.vertx.rxjava.core.streams.ReadStream#pipeTo} but with no completion handler.
* @param dst
*/
public void pipeTo(io.vertx.rxjava.core.streams.WriteStream dst) {
delegate.pipeTo(dst.getDelegate());
}
/**
* 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
* @param handler
*/
public void pipeTo(io.vertx.rxjava.core.streams.WriteStream dst, Handler> handler) {
delegate.pipeTo(dst.getDelegate(), handler);
}
/**
* 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
* @deprecated use {@link #rxPipeTo} instead
*/
@Deprecated()
public Observable pipeToObservable(io.vertx.rxjava.core.streams.WriteStream dst) {
io.vertx.rx.java.ObservableFuture handler = io.vertx.rx.java.RxHelper.observableFuture();
pipeTo(dst, handler.toHandler());
return handler;
}
/**
* 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 Single rxPipeTo(io.vertx.rxjava.core.streams.WriteStream dst) {
return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> {
pipeTo(dst, fut);
}));
}
/**
* When a WebSocket
is created it automatically registers an event handler with the event bus - the ID of that
* handler is given by this method.
*
* 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 String binaryHandlerID() {
String ret = delegate.binaryHandlerID();
return ret;
}
/**
* When a WebSocket
is created it automatically registers an event handler with the eventbus, the ID of that
* handler is given by textHandlerID
.
*
* 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
*/
public String textHandlerID() {
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 String subProtocol() {
String ret = delegate.subProtocol();
return ret;
}
/**
* Returns the status code received when the WebSocket was closed by the other side, otherwise null
.
* @return
*/
public Short closeStatusCode() {
Short ret = delegate.closeStatusCode();
return ret;
}
/**
* Returns the reason message received when the WebSocket was closed by the other side, otherwise null
.
* @return
*/
public String closeReason() {
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.rxjava.core.MultiMap headers() {
io.vertx.rxjava.core.MultiMap ret = io.vertx.rxjava.core.MultiMap.newInstance((io.vertx.core.MultiMap)delegate.headers());
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.vertx.rxjava.core.http.WebSocketBase writePing(io.vertx.rxjava.core.buffer.Buffer data) {
delegate.writePing(data.getDelegate());
return this;
}
/**
* 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.vertx.rxjava.core.http.WebSocketBase writePong(io.vertx.rxjava.core.buffer.Buffer data) {
delegate.writePong(data.getDelegate());
return this;
}
/**
* Set a text message handler on the connection. This handler will be called similar to the
* , 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.rxjava.core.http.WebSocketBase textMessageHandler(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.rxjava.core.http.ServerWebSocket#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.rxjava.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.rxjava.core.http.WebSocketBase binaryMessageHandler(Handler handler) {
delegate.binaryMessageHandler(new Handler() {
public void handle(io.vertx.core.buffer.Buffer event) {
handler.handle(io.vertx.rxjava.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.rxjava.core.http.WebSocketBase pongHandler(Handler handler) {
delegate.pongHandler(new Handler() {
public void handle(io.vertx.core.buffer.Buffer event) {
handler.handle(io.vertx.rxjava.core.buffer.Buffer.newInstance((io.vertx.core.buffer.Buffer)event));
}
});
return this;
}
/**
* Calls {@link io.vertx.rxjava.core.http.ServerWebSocket#close}
*/
public void end() {
delegate.end();
}
/**
* Calls {@link io.vertx.rxjava.core.http.WebSocketBase#close}
* @param handler
*/
public void end(Handler> handler) {
delegate.end(handler);
}
/**
* Calls {@link io.vertx.rxjava.core.http.WebSocketBase#close}
* @return
* @deprecated use {@link #rxEnd} instead
*/
@Deprecated()
public Observable endObservable() {
io.vertx.rx.java.ObservableFuture handler = io.vertx.rx.java.RxHelper.observableFuture();
end(handler.toHandler());
return handler;
}
/**
* Calls {@link io.vertx.rxjava.core.http.WebSocketBase#close}
* @return
*/
public Single rxEnd() {
return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> {
end(fut);
}));
}
/**
* Same as {@link io.vertx.rxjava.core.http.ServerWebSocket#close} but with an handler
called when the operation completes
* @param handler
*/
public void close(Handler> handler) {
delegate.close(handler);
}
/**
* Same as {@link io.vertx.rxjava.core.http.ServerWebSocket#close} but with an handler
called when the operation completes
* @return
* @deprecated use {@link #rxClose} instead
*/
@Deprecated()
public Observable closeObservable() {
io.vertx.rx.java.ObservableFuture handler = io.vertx.rx.java.RxHelper.observableFuture();
close(handler.toHandler());
return handler;
}
/**
* Same as {@link io.vertx.rxjava.core.http.ServerWebSocket#close} but with an handler
called when the operation completes
* @return
*/
public Single rxClose() {
return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> {
close(fut);
}));
}
/**
* 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 Status code
*/
public void close(short statusCode) {
delegate.close(statusCode);
}
/**
* Same as {@link io.vertx.rxjava.core.http.WebSocketBase#close} but with an handler
called when the operation completes
* @param statusCode
* @param handler
*/
public void close(short statusCode, Handler> handler) {
delegate.close(statusCode, handler);
}
/**
* Same as {@link io.vertx.rxjava.core.http.WebSocketBase#close} but with an handler
called when the operation completes
* @param statusCode
* @return
* @deprecated use {@link #rxClose} instead
*/
@Deprecated()
public Observable closeObservable(short statusCode) {
io.vertx.rx.java.ObservableFuture handler = io.vertx.rx.java.RxHelper.observableFuture();
close(statusCode, handler.toHandler());
return handler;
}
/**
* Same as {@link io.vertx.rxjava.core.http.WebSocketBase#close} but with an handler
called when the operation completes
* @param statusCode
* @return
*/
public Single rxClose(short statusCode) {
return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> {
close(statusCode, fut);
}));
}
/**
* 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 Status code
* @param reason reason of closure
*/
public void close(short statusCode, String reason) {
delegate.close(statusCode, reason);
}
/**
* Same as but with an handler
called when the operation completes
* @param statusCode
* @param reason
* @param handler
*/
public void close(short statusCode, String reason, Handler> handler) {
delegate.close(statusCode, reason, handler);
}
/**
* Same as but with an handler
called when the operation completes
* @param statusCode
* @param reason
* @return
* @deprecated use {@link #rxClose} instead
*/
@Deprecated()
public Observable closeObservable(short statusCode, String reason) {
io.vertx.rx.java.ObservableFuture handler = io.vertx.rx.java.RxHelper.observableFuture();
close(statusCode, reason, handler.toHandler());
return handler;
}
/**
* Same as but with an handler
called when the operation completes
* @param statusCode
* @param reason
* @return
*/
public Single rxClose(short statusCode, String reason) {
return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> {
close(statusCode, reason, fut);
}));
}
/**
* @return the remote address for this connection, possibly null
(e.g a server bound on a domain socket)
*/
public io.vertx.rxjava.core.net.SocketAddress remoteAddress() {
if (cached_0 != null) {
return cached_0;
}
io.vertx.rxjava.core.net.SocketAddress ret = io.vertx.rxjava.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)
*/
public io.vertx.rxjava.core.net.SocketAddress localAddress() {
if (cached_1 != null) {
return cached_1;
}
io.vertx.rxjava.core.net.SocketAddress ret = io.vertx.rxjava.core.net.SocketAddress.newInstance((io.vertx.core.net.SocketAddress)delegate.localAddress());
cached_1 = ret;
return ret;
}
/**
* @return true if this {@link io.vertx.rxjava.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;
}
public io.vertx.rxjava.core.http.ServerWebSocket exceptionHandler(Handler handler) {
delegate.exceptionHandler(handler);
return this;
}
public io.vertx.rxjava.core.http.ServerWebSocket handler(Handler handler) {
delegate.handler(new Handler() {
public void handle(io.vertx.core.buffer.Buffer event) {
handler.handle(io.vertx.rxjava.core.buffer.Buffer.newInstance((io.vertx.core.buffer.Buffer)event));
}
});
return this;
}
public io.vertx.rxjava.core.http.ServerWebSocket pause() {
delegate.pause();
return this;
}
public io.vertx.rxjava.core.http.ServerWebSocket resume() {
delegate.resume();
return this;
}
public io.vertx.rxjava.core.http.ServerWebSocket fetch(long amount) {
delegate.fetch(amount);
return this;
}
public io.vertx.rxjava.core.http.ServerWebSocket endHandler(Handler endHandler) {
delegate.endHandler(endHandler);
return this;
}
public io.vertx.rxjava.core.http.ServerWebSocket write(io.vertx.rxjava.core.buffer.Buffer data) {
delegate.write(data.getDelegate());
return this;
}
public io.vertx.rxjava.core.http.ServerWebSocket write(io.vertx.rxjava.core.buffer.Buffer data, Handler> handler) {
delegate.write(data.getDelegate(), handler);
return this;
}
@Deprecated()
public Observable writeObservable(io.vertx.rxjava.core.buffer.Buffer data) {
io.vertx.rx.java.ObservableFuture handler = io.vertx.rx.java.RxHelper.observableFuture();
write(data, handler.toHandler());
return handler;
}
public Single rxWrite(io.vertx.rxjava.core.buffer.Buffer data) {
return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> {
write(data, fut);
}));
}
public io.vertx.rxjava.core.http.ServerWebSocket setWriteQueueMaxSize(int maxSize) {
delegate.setWriteQueueMaxSize(maxSize);
return this;
}
public io.vertx.rxjava.core.http.ServerWebSocket drainHandler(Handler handler) {
delegate.drainHandler(handler);
return this;
}
public io.vertx.rxjava.core.http.ServerWebSocket writeFrame(io.vertx.rxjava.core.http.WebSocketFrame frame) {
delegate.writeFrame(frame.getDelegate());
return this;
}
public io.vertx.rxjava.core.http.ServerWebSocket writeFrame(io.vertx.rxjava.core.http.WebSocketFrame frame, Handler> handler) {
delegate.writeFrame(frame.getDelegate(), handler);
return this;
}
@Deprecated()
public Observable writeFrameObservable(io.vertx.rxjava.core.http.WebSocketFrame frame) {
io.vertx.rx.java.ObservableFuture handler = io.vertx.rx.java.RxHelper.observableFuture();
writeFrame(frame, handler.toHandler());
return handler;
}
public Single rxWriteFrame(io.vertx.rxjava.core.http.WebSocketFrame frame) {
return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> {
writeFrame(frame, fut);
}));
}
public io.vertx.rxjava.core.http.ServerWebSocket writeFinalTextFrame(String text) {
delegate.writeFinalTextFrame(text);
return this;
}
public io.vertx.rxjava.core.http.ServerWebSocket writeFinalTextFrame(String text, Handler> handler) {
delegate.writeFinalTextFrame(text, handler);
return this;
}
@Deprecated()
public Observable writeFinalTextFrameObservable(String text) {
io.vertx.rx.java.ObservableFuture handler = io.vertx.rx.java.RxHelper.observableFuture();
writeFinalTextFrame(text, handler.toHandler());
return handler;
}
public Single rxWriteFinalTextFrame(String text) {
return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> {
writeFinalTextFrame(text, fut);
}));
}
public io.vertx.rxjava.core.http.ServerWebSocket writeFinalBinaryFrame(io.vertx.rxjava.core.buffer.Buffer data) {
delegate.writeFinalBinaryFrame(data.getDelegate());
return this;
}
public io.vertx.rxjava.core.http.ServerWebSocket writeFinalBinaryFrame(io.vertx.rxjava.core.buffer.Buffer data, Handler> handler) {
delegate.writeFinalBinaryFrame(data.getDelegate(), handler);
return this;
}
@Deprecated()
public Observable writeFinalBinaryFrameObservable(io.vertx.rxjava.core.buffer.Buffer data) {
io.vertx.rx.java.ObservableFuture handler = io.vertx.rx.java.RxHelper.observableFuture();
writeFinalBinaryFrame(data, handler.toHandler());
return handler;
}
public Single rxWriteFinalBinaryFrame(io.vertx.rxjava.core.buffer.Buffer data) {
return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> {
writeFinalBinaryFrame(data, fut);
}));
}
public io.vertx.rxjava.core.http.ServerWebSocket writeBinaryMessage(io.vertx.rxjava.core.buffer.Buffer data) {
delegate.writeBinaryMessage(data.getDelegate());
return this;
}
public io.vertx.rxjava.core.http.ServerWebSocket writeBinaryMessage(io.vertx.rxjava.core.buffer.Buffer data, Handler> handler) {
delegate.writeBinaryMessage(data.getDelegate(), handler);
return this;
}
@Deprecated()
public Observable writeBinaryMessageObservable(io.vertx.rxjava.core.buffer.Buffer data) {
io.vertx.rx.java.ObservableFuture handler = io.vertx.rx.java.RxHelper.observableFuture();
writeBinaryMessage(data, handler.toHandler());
return handler;
}
public Single rxWriteBinaryMessage(io.vertx.rxjava.core.buffer.Buffer data) {
return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> {
writeBinaryMessage(data, fut);
}));
}
public io.vertx.rxjava.core.http.ServerWebSocket writeTextMessage(String text) {
delegate.writeTextMessage(text);
return this;
}
public io.vertx.rxjava.core.http.ServerWebSocket writeTextMessage(String text, Handler> handler) {
delegate.writeTextMessage(text, handler);
return this;
}
@Deprecated()
public Observable writeTextMessageObservable(String text) {
io.vertx.rx.java.ObservableFuture handler = io.vertx.rx.java.RxHelper.observableFuture();
writeTextMessage(text, handler.toHandler());
return handler;
}
public Single rxWriteTextMessage(String text) {
return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> {
writeTextMessage(text, fut);
}));
}
public io.vertx.rxjava.core.http.ServerWebSocket closeHandler(Handler handler) {
delegate.closeHandler(handler);
return this;
}
public io.vertx.rxjava.core.http.ServerWebSocket frameHandler(Handler handler) {
delegate.frameHandler(new Handler() {
public void handle(io.vertx.core.http.WebSocketFrame event) {
handler.handle(io.vertx.rxjava.core.http.WebSocketFrame.newInstance((io.vertx.core.http.WebSocketFrame)event));
}
});
return this;
}
public String uri() {
String ret = delegate.uri();
return ret;
}
/**
* @return the WebSocket handshake path.
*/
public String path() {
String ret = delegate.path();
return ret;
}
/**
* @return the WebSocket handshake query string.
*/
public String query() {
String ret = delegate.query();
return ret;
}
/**
* Accept the WebSocket and terminate the WebSocket handshake.
*
* This method should be called from the WebSocket handler to explicitly accept the WebSocket and
* terminate the WebSocket handshake.
*/
public void accept() {
delegate.accept();
}
/**
* Reject the WebSocket.
*
* Calling this method from the WebSocket handler when it is first passed to you gives you the opportunity to reject
* the WebSocket, which will cause the WebSocket handshake to fail by returning
* a response code.
*
* You might use this method, if for example you only want to accept WebSockets with a particular path.
*/
public void reject() {
delegate.reject();
}
/**
* Like {@link io.vertx.rxjava.core.http.ServerWebSocket#reject} but with a status
.
* @param status
*/
public void reject(int status) {
delegate.reject(status);
}
/**
* Set an asynchronous result for the handshake, upon completion of the specified future
, the
* WebSocket will either be
*
*
* - accepted when the
future
succeeds with the HTTP status code
* - rejected when the
future
is succeeds with an HTTP status code different than
* - rejected when the
future
fails with the HTTP status code 500
*
*
* The provided future might be completed by the WebSocket itself, e.g calling the {@link io.vertx.rxjava.core.http.ServerWebSocket#close} method
* will try to accept the handshake and close the WebSocket afterward. Thus it is advised to try to complete
* the future
with or .
*
* This method should be called from the WebSocket handler to explicitly set an asynchronous handshake.
*
* Calling this method will override the future
completion handler.
* @param future the future to complete with
* @param handler the completion handler
*/
public void setHandshake(io.vertx.rxjava.core.Future future, Handler> handler) {
delegate.setHandshake(future.getDelegate(), handler);
}
/**
* Set an asynchronous result for the handshake, upon completion of the specified future
, the
* WebSocket will either be
*
*
* - accepted when the
future
succeeds with the HTTP status code
* - rejected when the
future
is succeeds with an HTTP status code different than
* - rejected when the
future
fails with the HTTP status code 500
*
*
* The provided future might be completed by the WebSocket itself, e.g calling the {@link io.vertx.rxjava.core.http.ServerWebSocket#close} method
* will try to accept the handshake and close the WebSocket afterward. Thus it is advised to try to complete
* the future
with or .
*
* This method should be called from the WebSocket handler to explicitly set an asynchronous handshake.
*
* Calling this method will override the future
completion handler.
* @param future the future to complete with
* @return
* @deprecated use {@link #rxSetHandshake} instead
*/
@Deprecated()
public Observable setHandshakeObservable(io.vertx.rxjava.core.Future future) {
io.vertx.rx.java.ObservableFuture handler = io.vertx.rx.java.RxHelper.observableFuture();
setHandshake(future, handler.toHandler());
return handler;
}
/**
* Set an asynchronous result for the handshake, upon completion of the specified future
, the
* WebSocket will either be
*
*
* - accepted when the
future
succeeds with the HTTP status code
* - rejected when the
future
is succeeds with an HTTP status code different than
* - rejected when the
future
fails with the HTTP status code 500
*
*
* The provided future might be completed by the WebSocket itself, e.g calling the {@link io.vertx.rxjava.core.http.ServerWebSocket#close} method
* will try to accept the handshake and close the WebSocket afterward. Thus it is advised to try to complete
* the future
with or .
*
* This method should be called from the WebSocket handler to explicitly set an asynchronous handshake.
*
* Calling this method will override the future
completion handler.
* @param future the future to complete with
* @return
*/
public Single rxSetHandshake(io.vertx.rxjava.core.Future future) {
return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> {
setHandshake(future, fut);
}));
}
/**
* Like {@link io.vertx.rxjava.core.http.ServerWebSocket#setHandshake} but without a completion handler.
* @param future
*/
public void setHandshake(io.vertx.rxjava.core.Future future) {
delegate.setHandshake(future.getDelegate());
}
/**
*
*
*
* The WebSocket handshake will be accepted when it hasn't yet been settled or when an asynchronous handshake
* is in progress.
*/
public void close() {
delegate.close();
}
/**
* @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.rxjava.core.net.SocketAddress cached_0;
private io.vertx.rxjava.core.net.SocketAddress cached_1;
public static ServerWebSocket newInstance(io.vertx.core.http.ServerWebSocket arg) {
return arg != null ? new ServerWebSocket(arg) : null;
}
}