public class WebSocket extends Object implements WebSocketBase
original non RX-ified interface using Vert.x codegen.| Modifier and Type | Field and Description |
|---|---|
static TypeArg<WebSocket> |
__TYPE_ARG |
| Constructor and Description |
|---|
WebSocket(io.vertx.core.http.WebSocket delegate) |
| Modifier and Type | Method and Description |
|---|---|
String |
binaryHandlerID()
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. |
WebSocketBase |
binaryMessageHandler(Consumer<Buffer> handler)
Set a binary message handler on the connection.
|
CompletionStage<Void> |
close()
Same as
WebSocketBase.close() but with an handler called when the operation completes |
CompletionStage<Void> |
close(short statusCode)
Same as
WebSocketBase.close() but with an handler called when the operation completes |
CompletionStage<Void> |
close(short statusCode,
String reason)
Same as but with an
handler called when the operation completes |
WebSocket |
closeHandler(Consumer<Void> handler)
Set a close handler.
|
String |
closeReason()
Returns the reason message received when the WebSocket was closed by the other side, otherwise
null. |
Short |
closeStatusCode()
Returns the status code received when the WebSocket was closed by the other side, otherwise
null. |
WebSocket |
drainHandler(Consumer<Void> handler)
Set a drain handler on the stream.
|
CompletionStage<Void> |
end()
Calls
WebSocketBase.close() |
CompletionStage<Void> |
end(Buffer data)
Same as but with an
handler called when the operation completes |
WebSocket |
endHandler(Consumer<Void> endHandler)
Set an end handler.
|
boolean |
equals(Object o) |
WebSocket |
exceptionHandler(Consumer<Throwable> handler)
Set an exception handler on the read stream.
|
WebSocket |
fetch(long amount)
Fetch the specified
amount of elements. |
WebSocket |
frameHandler(Consumer<WebSocketFrame> handler)
Set a frame handler on the connection.
|
io.vertx.core.http.WebSocket |
getDelegate() |
WebSocket |
handler(Consumer<Buffer> handler)
Set a data handler.
|
int |
hashCode() |
MultiMap |
headers()
Returns the HTTP headers when the WebSocket is first obtained in the handler.
|
boolean |
isClosed() |
boolean |
isSsl() |
SocketAddress |
localAddress() |
static WebSocket |
newInstance(io.vertx.core.http.WebSocket arg) |
WebSocket |
pause()
Pause the
ReadStream, it sets the buffer in fetch mode and clears the actual demand. |
Pipe<Buffer> |
pipe()
Pause this stream and return a to transfer the elements of this stream to a destination .
|
CompletionStage<Void> |
pipeTo(WriteStream<Buffer> dst)
Pipe this
ReadStream to the WriteStream. |
WebSocketBase |
pongHandler(Consumer<Buffer> handler)
Set a pong frame handler on the connection.
|
SocketAddress |
remoteAddress() |
WebSocket |
resume()
Resume reading, and sets the buffer in
flowing mode. |
WebSocket |
setWriteQueueMaxSize(int maxSize)
Set the maximum size of the write queue to
maxSize. |
SSLSession |
sslSession() |
String |
subProtocol()
Returns the WebSocket sub protocol selected by the WebSocket handshake.
|
String |
textHandlerID()
When a
WebSocket is created it automatically registers an event handler with the eventbus, the ID of that
handler is given by textHandlerID. |
WebSocketBase |
textMessageHandler(Consumer<String> handler)
Set a text message handler on the connection.
|
org.reactivestreams.Publisher<Buffer> |
toPublisher() |
org.eclipse.microprofile.reactive.streams.operators.PublisherBuilder<Buffer> |
toPublisherBuilder() |
String |
toString() |
CompletionStage<Void> |
write(Buffer data)
Same as but with an
handler called when the operation completes |
CompletionStage<Void> |
writeBinaryMessage(Buffer data)
Same as
WebSocketBase.writeBinaryMessage(io.vertx.axle.core.buffer.Buffer) but with an handler called when the operation completes |
CompletionStage<Void> |
writeFinalBinaryFrame(Buffer data)
Same as
WebSocketBase.writeFinalBinaryFrame(io.vertx.axle.core.buffer.Buffer) but with an handler called when the operation completes |
CompletionStage<Void> |
writeFinalTextFrame(String text)
Same as
WebSocketBase.writeFinalTextFrame(java.lang.String) but with an handler called when the operation completes |
CompletionStage<Void> |
writeFrame(WebSocketFrame frame)
Same as
WebSocketBase.writeFrame(io.vertx.axle.core.http.WebSocketFrame) but with an handler called when the operation completes |
WebSocketBase |
writePing(Buffer data)
Writes a ping frame to the connection.
|
WebSocketBase |
writePong(Buffer data)
Writes a pong frame to the connection.
|
boolean |
writeQueueFull()
This will return
true if there are more bytes in the write queue than the value set using setWriteQueueMaxSize(int) |
CompletionStage<Void> |
writeTextMessage(String text)
Same as
WebSocketBase.writeTextMessage(java.lang.String) but with an handler called when the operation completes |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitnewInstancenewInstance, newInstancenewInstance, newInstancenewInstancepublic io.vertx.core.http.WebSocket getDelegate()
getDelegate in interface WebSocketBasegetDelegate in interface ReadStream<Buffer>getDelegate in interface StreamBasegetDelegate in interface WriteStream<Buffer>public org.reactivestreams.Publisher<Buffer> toPublisher()
toPublisher in interface ReadStream<Buffer>public org.eclipse.microprofile.reactive.streams.operators.PublisherBuilder<Buffer> toPublisherBuilder()
public CompletionStage<Void> end(Buffer data)
handler called when the operation completesend in interface WebSocketBaseend in interface WriteStream<Buffer>data - public boolean writeQueueFull()
true if there are more bytes in the write queue than the value set using setWriteQueueMaxSize(int)writeQueueFull in interface WebSocketBasewriteQueueFull in interface WriteStream<Buffer>public Pipe<Buffer> pipe()
WriteStream.pipe in interface WebSocketBasepipe in interface ReadStream<Buffer>public CompletionStage<Void> pipeTo(WriteStream<Buffer> dst)
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.
pipeTo in interface WebSocketBasepipeTo in interface ReadStream<Buffer>dst - the destination write streampublic String binaryHandlerID()
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.
binaryHandlerID in interface WebSocketBasepublic String textHandlerID()
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.
textHandlerID in interface WebSocketBasepublic String subProtocol()
null when the handler receives the websocket callback as the
handshake will not be completed yet.subProtocol in interface WebSocketBasepublic Short closeStatusCode()
null.closeStatusCode in interface WebSocketBasepublic String closeReason()
null.closeReason in interface WebSocketBasepublic MultiMap headers()
null on subsequent interactions.headers in interface WebSocketBasepublic WebSocketBase writePing(Buffer data)
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.
writePing in interface WebSocketBasedata - the data to write, may be at most 125 bytespublic WebSocketBase writePong(Buffer data)
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.
writePong in interface WebSocketBasedata - the data to write, may be at most 125 bytespublic WebSocketBase textMessageHandler(Consumer<String> handler)
textMessageHandler in interface WebSocketBasehandler - the handlerpublic WebSocketBase binaryMessageHandler(Consumer<Buffer> handler)
handler(java.util.function.Consumer<io.vertx.axle.core.buffer.Buffer>)
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 WebSocketFrame.isFinal() to find the boundaries).binaryMessageHandler in interface WebSocketBasehandler - the handlerpublic WebSocketBase pongHandler(Consumer<Buffer> handler)
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.
pongHandler in interface WebSocketBasehandler - the handlerpublic CompletionStage<Void> end()
WebSocketBase.close()end in interface WebSocketBaseend in interface WriteStream<Buffer>public CompletionStage<Void> close()
WebSocketBase.close() but with an handler called when the operation completesclose in interface WebSocketBasepublic CompletionStage<Void> close(short statusCode)
WebSocketBase.close() but with an handler called when the operation completesclose in interface WebSocketBasestatusCode - public CompletionStage<Void> close(short statusCode, String reason)
handler called when the operation completesclose in interface WebSocketBasestatusCode - reason - public SocketAddress remoteAddress()
remoteAddress in interface WebSocketBasepublic SocketAddress localAddress()
localAddress in interface WebSocketBasepublic boolean isSsl()
isSsl in interface WebSocketBaseHttpConnection is encrypted via SSL/TLS.public boolean isClosed()
isClosed in interface WebSocketBasetrue if the WebSocket is closedpublic WebSocket exceptionHandler(Consumer<Throwable> handler)
ReadStreamexceptionHandler in interface WebSocketBaseexceptionHandler in interface ReadStream<Buffer>exceptionHandler in interface StreamBaseexceptionHandler in interface WriteStream<Buffer>handler - the exception handlerpublic WebSocket handler(Consumer<Buffer> handler)
ReadStreamhandler in interface WebSocketBasehandler in interface ReadStream<Buffer>public WebSocket pause()
ReadStreamReadStream, it sets the buffer in fetch mode and clears the actual demand.
While it's paused, no data will be sent to the data handler.
pause in interface WebSocketBasepause in interface ReadStream<Buffer>public WebSocket resume()
ReadStreamflowing mode.
If the ReadStream has been paused, reading will recommence on it.resume in interface WebSocketBaseresume in interface ReadStream<Buffer>public WebSocket fetch(long amount)
ReadStreamamount of elements. If the ReadStream has been paused, reading will
recommence with the specified amount of items, otherwise the specified amount will
be added to the current stream demand.fetch in interface WebSocketBasefetch in interface ReadStream<Buffer>public WebSocket endHandler(Consumer<Void> endHandler)
ReadStreamendHandler in interface WebSocketBaseendHandler in interface ReadStream<Buffer>public CompletionStage<Void> write(Buffer data)
WriteStreamhandler called when the operation completeswrite in interface WebSocketBasewrite in interface WriteStream<Buffer>public WebSocket setWriteQueueMaxSize(int maxSize)
WriteStreammaxSize. You will still be able to write to the stream even
if there is more than maxSize items in the write queue. This is used as an indicator by classes such as
Pump to provide flow control.
The value is defined by the implementation of the stream, e.g in bytes for a
NetSocket, the number of Message for a
MessageProducer, etc...setWriteQueueMaxSize in interface WebSocketBasesetWriteQueueMaxSize in interface WriteStream<Buffer>maxSize - the max size of the write streampublic WebSocket drainHandler(Consumer<Void> handler)
WriteStreamPump for an example of this being used.
The stream implementation defines when the drain handler, for example it could be when the queue size has been
reduced to maxSize / 2.drainHandler in interface WebSocketBasedrainHandler in interface WriteStream<Buffer>handler - the handlerpublic CompletionStage<Void> writeFrame(WebSocketFrame frame)
WebSocketBaseWebSocketBase.writeFrame(io.vertx.axle.core.http.WebSocketFrame) but with an handler called when the operation completeswriteFrame in interface WebSocketBasepublic CompletionStage<Void> writeFinalTextFrame(String text)
WebSocketBaseWebSocketBase.writeFinalTextFrame(java.lang.String) but with an handler called when the operation completeswriteFinalTextFrame in interface WebSocketBasepublic CompletionStage<Void> writeFinalBinaryFrame(Buffer data)
WebSocketBaseWebSocketBase.writeFinalBinaryFrame(io.vertx.axle.core.buffer.Buffer) but with an handler called when the operation completeswriteFinalBinaryFrame in interface WebSocketBasepublic CompletionStage<Void> writeBinaryMessage(Buffer data)
WebSocketBaseWebSocketBase.writeBinaryMessage(io.vertx.axle.core.buffer.Buffer) but with an handler called when the operation completeswriteBinaryMessage in interface WebSocketBasepublic CompletionStage<Void> writeTextMessage(String text)
WebSocketBaseWebSocketBase.writeTextMessage(java.lang.String) but with an handler called when the operation completeswriteTextMessage in interface WebSocketBasepublic WebSocket closeHandler(Consumer<Void> handler)
WebSocketBaseWebSocketBase.closeStatusCode() will return the status code and WebSocketBase.closeReason() will return the reason.closeHandler in interface WebSocketBasehandler - the handlerpublic WebSocket frameHandler(Consumer<WebSocketFrame> handler)
WebSocketBaseframeHandler in interface WebSocketBasehandler - the handlerpublic SSLSession sslSession()
sslSession in interface WebSocketBasepublic static WebSocket newInstance(io.vertx.core.http.WebSocket arg)
Copyright © 2019 SmallRye. All rights reserved.