public class DefaultWebSocket extends ServerWebSocket
Modifier and Type | Field and Description |
---|---|
protected boolean |
closed |
path
binaryHandlerID, 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()
ServerWebSocket
Calling 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 ServerWebSocket
public void writeBinaryFrame(Buffer data)
WebSocket
data
to the websocket as a binary framewriteBinaryFrame
in class WebSocket
public void writeTextFrame(java.lang.String str)
WebSocket
str
to the websocket as a text framewriteTextFrame
in class WebSocket
public void dataHandler(Handler<Buffer> handler)
ReadStream
public void endHandler(Handler<java.lang.Void> handler)
ReadStream
public void exceptionHandler(Handler<java.lang.Exception> handler)
ReadStream
public void closedHandler(Handler<java.lang.Void> handler)
WebSocket
closedHandler
in class WebSocket
public void pause()
ReadStream
ReadStream
. While the stream is paused, no data will be sent to the dataHandler
public void resume()
ReadStream
ReadStream
has been paused, reading will recommence on it.public void setWriteQueueMaxSize(int maxSize)
WriteStream
maxSize
. 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()
WriteStream
true
if there are more bytes in the write queue than the value set using WriteStream.setWriteQueueMaxSize(int)
public void writeBuffer(Buffer data)
WriteStream
WriteStream.writeQueueFull()
method before writing. This is done automatically if using a Pump
.public void drainHandler(Handler<java.lang.Void> handler)
WriteStream
Pump
for an example of this being used.public void close()
WebSocket
protected void writeFrame(WebSocketFrame frame)
protected void checkClosed()