public interface WebSocketBase extends ReadStream<Buffer>, WriteStream<Buffer>
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(Handler<Buffer> handler)
Set a binary message handler on the connection.
|
void |
close()
Same as
close(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>) but with an handler called when the operation completes |
void |
close(Handler<AsyncResult<Void>> handler)
Same as
close(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>) but with an handler called when the operation completes |
void |
close(short statusCode)
Same as
close(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>) but with an handler called when the operation completes |
void |
close(short statusCode,
Handler<AsyncResult<Void>> handler)
Same as
close(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>) but with an handler called when the operation completes |
void |
close(short statusCode,
String reason)
Same as but with an
handler called when the operation completes |
void |
close(short statusCode,
String reason,
Handler<AsyncResult<Void>> handler)
Same as but with an
handler called when the operation completes |
WebSocketBase |
closeHandler(Handler<Void> handler)
Set a close handler.
|
String |
closeReason()
Returns the close reason message from the remote endpoint or
null when not yet received. |
Short |
closeStatusCode()
Returns the close status code received from the remote endpoint or
null when not yet received. |
WebSocketBase |
drainHandler(Handler<Void> handler)
Set a drain handler on the stream.
|
void |
end()
|
void |
end(Buffer data)
Same as but with an
handler called when the operation completes |
void |
end(Buffer data,
Handler<AsyncResult<Void>> handler)
Same as but with an
handler called when the operation completes |
void |
end(Handler<AsyncResult<Void>> handler)
|
WebSocketBase |
endHandler(Handler<Void> endHandler)
Set an end handler.
|
WebSocketBase |
exceptionHandler(Handler<Throwable> handler)
Set an exception handler on the read stream.
|
WebSocketBase |
fetch(long amount)
Fetch the specified
amount of elements. |
WebSocketBase |
frameHandler(Handler<WebSocketFrame> handler)
Set a frame handler on the connection.
|
WebSocketBase |
getDelegate() |
WebSocketBase |
handler(Handler<Buffer> handler)
Set a data handler.
|
MultiMap |
headers()
Returns the HTTP headers when the WebSocket is first obtained in the handler.
|
boolean |
isClosed() |
boolean |
isSsl() |
SocketAddress |
localAddress() |
static WebSocketBase |
newInstance(WebSocketBase arg) |
WebSocketBase |
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 .
|
void |
pipeTo(WriteStream<Buffer> dst)
Pipe this
ReadStream to the WriteStream . |
void |
pipeTo(WriteStream<Buffer> dst,
Handler<AsyncResult<Void>> handler)
Pipe this
ReadStream to the WriteStream . |
WebSocketBase |
pongHandler(Handler<Buffer> handler)
Set a pong frame handler on the connection.
|
SocketAddress |
remoteAddress() |
WebSocketBase |
resume()
Resume reading, and sets the buffer in
flowing mode. |
Completable |
rxClose()
Same as
close(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>) but with an handler called when the operation completes |
Completable |
rxClose(short statusCode)
Same as
close(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>) but with an handler called when the operation completes |
Completable |
rxClose(short statusCode,
String reason)
Same as but with an
handler called when the operation completes |
Completable |
rxEnd()
|
Completable |
rxEnd(Buffer data)
Same as but with an
handler called when the operation completes |
Completable |
rxPipeTo(WriteStream<Buffer> dst)
Pipe this
ReadStream to the WriteStream . |
Completable |
rxWrite(Buffer data)
Same as but with an
handler called when the operation completes |
Completable |
rxWriteBinaryMessage(Buffer data)
Same as
writeBinaryMessage(io.vertx.reactivex.core.buffer.Buffer, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>) but with an handler called when the operation completes |
Completable |
rxWriteFinalBinaryFrame(Buffer data)
Same as
writeFinalBinaryFrame(io.vertx.reactivex.core.buffer.Buffer, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>) but with an handler called when the operation completes |
Completable |
rxWriteFinalTextFrame(String text)
Same as
writeFinalTextFrame(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>) but with an handler called when the operation completes |
Completable |
rxWriteFrame(WebSocketFrame frame)
Same as
writeFrame(io.vertx.reactivex.core.http.WebSocketFrame, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>) but with an handler called when the operation completes |
Completable |
rxWritePing(Buffer data)
Writes a ping frame to the connection.
|
Completable |
rxWritePong(Buffer data)
Writes a pong frame to the connection.
|
Completable |
rxWriteTextMessage(String text)
Same as
writeTextMessage(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>) but with an handler called when the operation completes |
WebSocketBase |
setWriteQueueMaxSize(int maxSize)
Set the maximum size of the write queue to
maxSize . |
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(Handler<String> handler)
Set a text message handler on the connection.
|
void |
write(Buffer data)
Same as but with an
handler called when the operation completes |
void |
write(Buffer data,
Handler<AsyncResult<Void>> handler)
Same as but with an
handler called when the operation completes |
WebSocketBase |
writeBinaryMessage(Buffer data)
Same as
writeBinaryMessage(io.vertx.reactivex.core.buffer.Buffer, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>) but with an handler called when the operation completes |
WebSocketBase |
writeBinaryMessage(Buffer data,
Handler<AsyncResult<Void>> handler)
Same as
writeBinaryMessage(io.vertx.reactivex.core.buffer.Buffer, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>) but with an handler called when the operation completes |
WebSocketBase |
writeFinalBinaryFrame(Buffer data)
Same as
writeFinalBinaryFrame(io.vertx.reactivex.core.buffer.Buffer, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>) but with an handler called when the operation completes |
WebSocketBase |
writeFinalBinaryFrame(Buffer data,
Handler<AsyncResult<Void>> handler)
Same as
writeFinalBinaryFrame(io.vertx.reactivex.core.buffer.Buffer, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>) but with an handler called when the operation completes |
WebSocketBase |
writeFinalTextFrame(String text)
Same as
writeFinalTextFrame(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>) but with an handler called when the operation completes |
WebSocketBase |
writeFinalTextFrame(String text,
Handler<AsyncResult<Void>> handler)
Same as
writeFinalTextFrame(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>) but with an handler called when the operation completes |
WebSocketBase |
writeFrame(WebSocketFrame frame)
Same as
writeFrame(io.vertx.reactivex.core.http.WebSocketFrame, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>) but with an handler called when the operation completes |
WebSocketBase |
writeFrame(WebSocketFrame frame,
Handler<AsyncResult<Void>> handler)
Same as
writeFrame(io.vertx.reactivex.core.http.WebSocketFrame, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>) but with an handler called when the operation completes |
WebSocketBase |
writePing(Buffer data)
Writes a ping frame to the connection.
|
WebSocketBase |
writePing(Buffer data,
Handler<AsyncResult<Void>> handler)
Writes a ping frame to the connection.
|
WebSocketBase |
writePong(Buffer data)
Writes a pong frame to the connection.
|
WebSocketBase |
writePong(Buffer data,
Handler<AsyncResult<Void>> handler)
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) |
WebSocketBase |
writeTextMessage(String text)
Same as
writeTextMessage(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>) but with an handler called when the operation completes |
WebSocketBase |
writeTextMessage(String text,
Handler<AsyncResult<Void>> handler)
Same as
writeTextMessage(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>) but with an handler called when the operation completes |
newInstance, newInstance, toFlowable, toObservable
newInstance, newInstance
newInstance
WebSocketBase getDelegate()
getDelegate
in interface ReadStream<Buffer>
getDelegate
in interface StreamBase
getDelegate
in interface WriteStream<Buffer>
void write(Buffer data, Handler<AsyncResult<Void>> handler)
handler
called when the operation completeswrite
in interface WriteStream<Buffer>
data
- handler
- void write(Buffer data)
handler
called when the operation completeswrite
in interface WriteStream<Buffer>
data
- Completable rxWrite(Buffer data)
handler
called when the operation completesrxWrite
in interface WriteStream<Buffer>
data
- void end(Buffer data, Handler<AsyncResult<Void>> handler)
handler
called when the operation completesend
in interface WriteStream<Buffer>
data
- handler
- void end(Buffer data)
handler
called when the operation completesend
in interface WriteStream<Buffer>
data
- Completable rxEnd(Buffer data)
handler
called when the operation completesrxEnd
in interface WriteStream<Buffer>
data
- boolean writeQueueFull()
true
if there are more bytes in the write queue than the value set using setWriteQueueMaxSize(int)
writeQueueFull
in interface WriteStream<Buffer>
true
if write queue is fullPipe<Buffer> pipe()
WriteStream
.pipe
in interface ReadStream<Buffer>
void pipeTo(WriteStream<Buffer> dst, Handler<AsyncResult<Void>> handler)
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 ReadStream<Buffer>
dst
- the destination write streamhandler
- 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 ReadStream<Buffer>
dst
- the destination write streamCompletable rxPipeTo(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.
rxPipeTo
in interface ReadStream<Buffer>
dst
- the destination write streamWebSocketBase exceptionHandler(Handler<Throwable> handler)
ReadStream
exceptionHandler
in interface ReadStream<Buffer>
exceptionHandler
in interface StreamBase
exceptionHandler
in interface WriteStream<Buffer>
handler
- the exception handlerWebSocketBase handler(Handler<Buffer> handler)
ReadStream
handler
in interface ReadStream<Buffer>
WebSocketBase pause()
ReadStream
ReadStream
, 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 ReadStream<Buffer>
WebSocketBase resume()
ReadStream
flowing
mode.
If the ReadStream
has been paused, reading will recommence on it.resume
in interface ReadStream<Buffer>
WebSocketBase fetch(long amount)
ReadStream
amount
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 ReadStream<Buffer>
WebSocketBase endHandler(Handler<Void> endHandler)
ReadStream
endHandler
in interface ReadStream<Buffer>
WebSocketBase setWriteQueueMaxSize(int maxSize)
WriteStream
maxSize
. 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
Pipe
to provide flow control.
The value is defined by the implementation of the stream, e.g in bytes for a
NetSocket
, etc...setWriteQueueMaxSize
in interface WriteStream<Buffer>
maxSize
- the max size of the write streamWebSocketBase drainHandler(Handler<Void> handler)
WriteStream
Pipe
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 WriteStream<Buffer>
handler
- the handlerString 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.
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.
String subProtocol()
null
when the handler receives the WebSocket callback as the
handshake will not be completed yet.Short closeStatusCode()
null
when not yet received.String closeReason()
null
when not yet received.MultiMap headers()
null
on subsequent interactions.WebSocketBase writeFrame(WebSocketFrame frame, Handler<AsyncResult<Void>> handler)
writeFrame(io.vertx.reactivex.core.http.WebSocketFrame, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with an handler
called when the operation completesframe
- handler
- WebSocketBase writeFrame(WebSocketFrame frame)
writeFrame(io.vertx.reactivex.core.http.WebSocketFrame, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with an handler
called when the operation completesframe
- Completable rxWriteFrame(WebSocketFrame frame)
writeFrame(io.vertx.reactivex.core.http.WebSocketFrame, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with an handler
called when the operation completesframe
- WebSocketBase writeFinalTextFrame(String text, Handler<AsyncResult<Void>> handler)
writeFinalTextFrame(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with an handler
called when the operation completestext
- handler
- WebSocketBase writeFinalTextFrame(String text)
writeFinalTextFrame(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with an handler
called when the operation completestext
- Completable rxWriteFinalTextFrame(String text)
writeFinalTextFrame(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with an handler
called when the operation completestext
- WebSocketBase writeFinalBinaryFrame(Buffer data, Handler<AsyncResult<Void>> handler)
writeFinalBinaryFrame(io.vertx.reactivex.core.buffer.Buffer, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with an handler
called when the operation completesdata
- handler
- WebSocketBase writeFinalBinaryFrame(Buffer data)
writeFinalBinaryFrame(io.vertx.reactivex.core.buffer.Buffer, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with an handler
called when the operation completesdata
- Completable rxWriteFinalBinaryFrame(Buffer data)
writeFinalBinaryFrame(io.vertx.reactivex.core.buffer.Buffer, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with an handler
called when the operation completesdata
- WebSocketBase writeBinaryMessage(Buffer data, Handler<AsyncResult<Void>> handler)
writeBinaryMessage(io.vertx.reactivex.core.buffer.Buffer, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with an handler
called when the operation completesdata
- handler
- WebSocketBase writeBinaryMessage(Buffer data)
writeBinaryMessage(io.vertx.reactivex.core.buffer.Buffer, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with an handler
called when the operation completesdata
- Completable rxWriteBinaryMessage(Buffer data)
writeBinaryMessage(io.vertx.reactivex.core.buffer.Buffer, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with an handler
called when the operation completesdata
- WebSocketBase writeTextMessage(String text, Handler<AsyncResult<Void>> handler)
writeTextMessage(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with an handler
called when the operation completestext
- handler
- WebSocketBase writeTextMessage(String text)
writeTextMessage(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with an handler
called when the operation completestext
- Completable rxWriteTextMessage(String text)
writeTextMessage(java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with an handler
called when the operation completestext
- WebSocketBase writePing(Buffer data, Handler<AsyncResult<Void>> handler)
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.
data
- the data to write, may be at most 125 byteshandler
- called when the ping frame has been successfully writtenWebSocketBase 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.
data
- the data to write, may be at most 125 bytesCompletable rxWritePing(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.
data
- the data to write, may be at most 125 bytesWebSocketBase writePong(Buffer data, Handler<AsyncResult<Void>> handler)
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.
data
- the data to write, may be at most 125 byteshandler
- called when the pong frame has been successfully writtenWebSocketBase 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.
data
- the data to write, may be at most 125 bytesCompletable rxWritePong(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.
data
- the data to write, may be at most 125 bytesWebSocketBase closeHandler(Handler<Void> handler)
closeStatusCode()
will return the status code and closeReason()
will return the reason.handler
- the handlerWebSocketBase frameHandler(Handler<WebSocketFrame> handler)
handler
- the handlerWebSocketBase textMessageHandler(Handler<String> handler)
handler
- the handlerWebSocketBase binaryMessageHandler(Handler<Buffer> handler)
handler(io.vertx.core.Handler<io.vertx.reactivex.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).handler
- the handlerWebSocketBase pongHandler(Handler<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.
handler
- the handlervoid end(Handler<AsyncResult<Void>> handler)
end
in interface WriteStream<Buffer>
handler
- void end()
end
in interface WriteStream<Buffer>
Completable rxEnd()
rxEnd
in interface WriteStream<Buffer>
void close(Handler<AsyncResult<Void>> handler)
close(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with an handler
called when the operation completeshandler
- void close()
close(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with an handler
called when the operation completesCompletable rxClose()
close(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with an handler
called when the operation completesvoid close(short statusCode, Handler<AsyncResult<Void>> handler)
close(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with an handler
called when the operation completesstatusCode
- handler
- void close(short statusCode)
close(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with an handler
called when the operation completesstatusCode
- Completable rxClose(short statusCode)
close(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with an handler
called when the operation completesstatusCode
- void close(short statusCode, String reason, Handler<AsyncResult<Void>> handler)
handler
called when the operation completesstatusCode
- reason
- handler
- void close(short statusCode, String reason)
handler
called when the operation completesstatusCode
- reason
- Completable rxClose(short statusCode, String reason)
handler
called when the operation completesstatusCode
- reason
- SocketAddress remoteAddress()
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.SocketAddress localAddress()
null
(e.g a server bound on a domain socket) If useProxyProtocol
is set to true
, the address returned will be of the proxy.boolean isSsl()
HttpConnection
is encrypted via SSL/TLS.boolean isClosed()
true
if the WebSocket is closedstatic WebSocketBase newInstance(WebSocketBase arg)
Copyright © 2022 Eclipse. All rights reserved.