public class DefaultWebSocket extends ServerWebSocket
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
closed |
pathbinaryHandlerID, textHandlerID| Modifier | Constructor and Description |
|---|---|
protected |
DefaultWebSocket(VertxInternal vertx,
java.lang.String path,
AbstractConnection conn,
java.lang.Runnable connectRunnable) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
checkClosed() |
void |
close()
Close the websocket
|
void |
closedHandler(Handler<java.lang.Void> handler)
Set a closed handler on the connection
|
void |
dataHandler(Handler<Buffer> handler)
Set a data handler.
|
void |
drainHandler(Handler<java.lang.Void> handler)
Set a drain handler on the stream.
|
void |
endHandler(Handler<java.lang.Void> handler)
Set an end handler.
|
void |
exceptionHandler(Handler<java.lang.Exception> handler)
Set an exception handler.
|
void |
pause()
Pause the
ReadStream. |
void |
reject()
Reject the WebSocket
|
void |
resume()
Resume reading.
|
void |
setWriteQueueMaxSize(int maxSize)
Set the maximum size of the write queue to
maxSize. |
void |
writeBinaryFrame(Buffer data)
Write
data to the websocket as a binary frame |
void |
writeBuffer(Buffer data)
Write some data to the stream.
|
protected void |
writeFrame(WebSocketFrame frame) |
boolean |
writeQueueFull()
This will return
true if there are more bytes in the write queue than the value set using WriteStream.setWriteQueueMaxSize(int) |
void |
writeTextFrame(java.lang.String str)
Write
str to the websocket as a text frame |
protected DefaultWebSocket(VertxInternal vertx, java.lang.String path, AbstractConnection conn, java.lang.Runnable connectRunnable)
public void reject()
ServerWebSocketCalling this method from the websocketHandler gives you the opportunity to reject the websocket, which will cause the websocket handshake to fail by returning a 404 response code.
You might use this method, if for example you only want to accept websockets with a particular path.
reject in class ServerWebSocketpublic void writeBinaryFrame(Buffer data)
WebSocketdata to the websocket as a binary framewriteBinaryFrame in class WebSocketpublic void writeTextFrame(java.lang.String str)
WebSocketstr to the websocket as a text framewriteTextFrame in class WebSocketpublic void dataHandler(Handler<Buffer> handler)
ReadStreampublic void endHandler(Handler<java.lang.Void> handler)
ReadStreampublic void exceptionHandler(Handler<java.lang.Exception> handler)
ReadStreampublic void closedHandler(Handler<java.lang.Void> handler)
WebSocketclosedHandler in class WebSocketpublic void pause()
ReadStreamReadStream. While the stream is paused, no data will be sent to the dataHandlerpublic void resume()
ReadStreamReadStream has been paused, reading will recommence on it.public void setWriteQueueMaxSize(int maxSize)
WriteStreammaxSize. You will still be able to write to the stream even
if there is more than maxSize bytes in the write queue. This is used as an indicator by classes such as
Pump to provide flow control.public boolean writeQueueFull()
WriteStreamtrue if there are more bytes in the write queue than the value set using WriteStream.setWriteQueueMaxSize(int)public void writeBuffer(Buffer data)
WriteStreamWriteStream.writeQueueFull() method before writing. This is done automatically if using a Pump.public void drainHandler(Handler<java.lang.Void> handler)
WriteStreamPump for an example of this being used.public void close()
WebSocketprotected void writeFrame(WebSocketFrame frame)
protected void checkClosed()