public interface WebSocketBase<T> extends ReadStream<T>, WriteStream<T>
Instances of this class are created and provided to the handler of an
HttpClient
when a successful websocket connect attempt occurs.
On the server side, the subclass ServerWebSocket
is used instead.
It implements both ReadStream
and WriteStream
so it can be used with
Pump
to pump data with flow control.
Instances of this class are not thread-safe
Modifier and Type | Method and Description |
---|---|
java.lang.String |
binaryHandlerID()
When a
Websocket is created it automatically registers an event handler with the eventbus, the ID of that
handler is given by binaryHandlerID . |
void |
close()
Close the websocket
|
T |
closeHandler(Handler<java.lang.Void> handler)
Set a closed handler on the connection
|
java.net.InetSocketAddress |
localAddress()
Return the local address for this socket
|
java.net.InetSocketAddress |
remoteAddress()
Return the remote address for this socket
|
java.lang.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 . |
T |
writeBinaryFrame(Buffer data)
Write
data to the websocket as a binary frame |
T |
writeTextFrame(java.lang.String str)
Write
str to the websocket as a text frame |
endHandler
dataHandler, pause, resume
exceptionHandler
write
drainHandler, setWriteQueueMaxSize, writeQueueFull
java.lang.String binaryHandlerID()
Websocket
is created it automatically registers an event handler with the eventbus, the ID of that
handler is given by binaryHandlerID
.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.
java.lang.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.
T writeTextFrame(java.lang.String str)
str
to the websocket as a text framevoid close()
java.net.InetSocketAddress remoteAddress()
java.net.InetSocketAddress localAddress()