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 |
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()
Close the WebSocket.
|
WebSocket |
closeHandler(Handler<Void> handler)
Set a close handler.
|
WebSocket |
drainHandler(Handler<Void> handler)
Set a drain handler on the stream.
|
void |
end()
Calls
WebSocketBase.close() |
void |
end(Buffer t)
Same as
WebSocketBase.end(io.vertx.rxjava.core.buffer.Buffer) but writes some data to the stream before ending. |
WebSocket |
endHandler(Handler<Void> endHandler)
Set an end handler.
|
WebSocket |
exceptionHandler(Handler<Throwable> handler)
Set an exception handler on the read stream.
|
WebSocket |
frameHandler(Handler<WebSocketFrame> handler)
Set a frame handler on the connection.
|
WebSocket |
getDelegate() |
WebSocket |
handler(Handler<Buffer> handler)
Set a data handler.
|
boolean |
isSsl() |
SocketAddress |
localAddress() |
static WebSocket |
newInstance(WebSocket arg) |
WebSocket |
pause()
Pause the
ReadSupport . |
SocketAddress |
remoteAddress() |
WebSocket |
resume()
Resume reading.
|
WebSocket |
setWriteQueueMaxSize(int maxSize)
Set the maximum size of the write queue to
maxSize . |
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.
|
Observable<Buffer> |
toObservable() |
WebSocket |
write(Buffer data)
Write some data to the stream.
|
WebSocket |
writeBinaryMessage(Buffer data)
Writes a (potentially large) piece of binary data to the connection.
|
WebSocket |
writeFinalBinaryFrame(Buffer data)
Write a final WebSocket binary frame to the connection
|
WebSocket |
writeFinalTextFrame(String text)
Write a final WebSocket text frame to the connection
|
WebSocket |
writeFrame(WebSocketFrame frame)
Write a WebSocket 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) |
WebSocket |
writeTextMessage(String text)
Writes a (potentially large) piece of text data to the connection.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
newInstance
newInstance, newInstance
newInstance, newInstance
newInstance
public WebSocket(WebSocket delegate)
public WebSocket getDelegate()
getDelegate
in interface WebSocketBase
getDelegate
in interface ReadStream<Buffer>
getDelegate
in interface StreamBase
getDelegate
in interface WriteStream<Buffer>
public Observable<Buffer> toObservable()
toObservable
in interface ReadStream<Buffer>
public void end(Buffer t)
WebSocketBase.end(io.vertx.rxjava.core.buffer.Buffer)
but writes some data to the stream before ending.end
in interface WebSocketBase
end
in interface WriteStream<Buffer>
t
- public boolean writeQueueFull()
true
if there are more bytes in the write queue than the value set using setWriteQueueMaxSize(int)
writeQueueFull
in interface WebSocketBase
writeQueueFull
in interface WriteStream<Buffer>
public 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 WebSocketBase
public 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 WebSocketBase
public WebSocketBase textMessageHandler(Handler<String> handler)
textMessageHandler
in interface WebSocketBase
handler
- the handlerpublic WebSocketBase binaryMessageHandler(Handler<Buffer> handler)
handler(io.vertx.core.Handler<io.vertx.rxjava.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 WebSocketBase
handler
- the handlerpublic void end()
WebSocketBase.close()
end
in interface WebSocketBase
end
in interface WriteStream<Buffer>
public void close()
close
in interface WebSocketBase
public SocketAddress remoteAddress()
remoteAddress
in interface WebSocketBase
public SocketAddress localAddress()
localAddress
in interface WebSocketBase
public boolean isSsl()
isSsl
in interface WebSocketBase
HttpConnection
is encrypted via SSL/TLS.public WebSocket exceptionHandler(Handler<Throwable> handler)
ReadStream
exceptionHandler
in interface WebSocketBase
exceptionHandler
in interface ReadStream<Buffer>
exceptionHandler
in interface StreamBase
exceptionHandler
in interface WriteStream<Buffer>
handler
- the exception handlerpublic WebSocket handler(Handler<Buffer> handler)
ReadStream
handler
in interface WebSocketBase
handler
in interface ReadStream<Buffer>
public WebSocket pause()
ReadStream
ReadSupport
. While it's paused, no data will be sent to the dataHandler
pause
in interface WebSocketBase
pause
in interface ReadStream<Buffer>
public WebSocket resume()
ReadStream
ReadSupport
has been paused, reading will recommence on it.resume
in interface WebSocketBase
resume
in interface ReadStream<Buffer>
public WebSocket endHandler(Handler<Void> endHandler)
ReadStream
endHandler
in interface WebSocketBase
endHandler
in interface ReadStream<Buffer>
public WebSocket write(Buffer data)
WriteStream
WriteStream.writeQueueFull()
method before writing. This is done automatically if using a Pump
.write
in interface WebSocketBase
write
in interface WriteStream<Buffer>
data
- the data to writepublic WebSocket 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
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 WebSocketBase
setWriteQueueMaxSize
in interface WriteStream<Buffer>
maxSize
- the max size of the write streampublic WebSocket drainHandler(Handler<Void> handler)
WriteStream
Pump
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 WebSocketBase
drainHandler
in interface WriteStream<Buffer>
handler
- the handlerpublic WebSocket writeFrame(WebSocketFrame frame)
WebSocketBase
writeFrame
in interface WebSocketBase
frame
- the frame to writepublic WebSocket writeFinalTextFrame(String text)
WebSocketBase
writeFinalTextFrame
in interface WebSocketBase
text
- The text to writepublic WebSocket writeFinalBinaryFrame(Buffer data)
WebSocketBase
writeFinalBinaryFrame
in interface WebSocketBase
data
- The data to writepublic WebSocket writeBinaryMessage(Buffer data)
WebSocketBase
writeBinaryMessage
in interface WebSocketBase
data
- the data to writepublic WebSocket writeTextMessage(String text)
WebSocketBase
writeTextMessage
in interface WebSocketBase
text
- the data to writepublic WebSocket closeHandler(Handler<Void> handler)
WebSocketBase
closeHandler
in interface WebSocketBase
handler
- the handlerpublic WebSocket frameHandler(Handler<WebSocketFrame> handler)
WebSocketBase
frameHandler
in interface WebSocketBase
handler
- the handlerCopyright © 2017. All rights reserved.