public abstract class WebSocket extends java.lang.Object implements ReadStream, WriteStream
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 | Field 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 . |
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 . |
Modifier | Constructor and Description |
---|---|
protected |
WebSocket(java.lang.String binaryHandlerID,
java.lang.String textHandlerID) |
Modifier and Type | Method and Description |
---|---|
abstract void |
close()
Close the websocket
|
abstract void |
closedHandler(Handler<java.lang.Void> handler)
Set a closed handler on the connection
|
abstract void |
writeBinaryFrame(Buffer data)
Write
data to the websocket as a binary frame |
abstract void |
writeTextFrame(java.lang.String str)
Write
str to the websocket as a text frame |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
dataHandler, endHandler, exceptionHandler, pause, resume
drainHandler, exceptionHandler, setWriteQueueMaxSize, writeBuffer, writeQueueFull
public final 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.
public final 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.
protected WebSocket(java.lang.String binaryHandlerID, java.lang.String textHandlerID)
public abstract void writeBinaryFrame(Buffer data)
data
to the websocket as a binary framepublic abstract void writeTextFrame(java.lang.String str)
str
to the websocket as a text framepublic abstract void closedHandler(Handler<java.lang.Void> handler)
public abstract void close()