public interface ServerWebSocket extends WebSocketBase
Represents a server side WebSocket that is passed into a the websocketHandler of an HttpServer
<p>
Instances of this class are not thread-safe<p>
Modifier and Type | Method and Description |
---|---|
ServerWebSocket |
closeHandler(Handler<Void> handler)
Set a closed handler on the connection
|
ServerWebSocket |
drainHandler(Handler<Void> handler)
Set a drain handler on the stream.
|
ServerWebSocket |
endHandler(Handler<Void> endHandler)
Set an end handler.
|
ServerWebSocket |
exceptionHandler(Handler<Throwable> handler)
Set an exception handler.
|
ServerWebSocket |
frameHandler(Handler<WebSocketFrame> handler)
Set a frame handler on the connection
|
ServerWebSocket |
handler(Handler<Buffer> handler)
Set a data handler.
|
MultiMap |
headers()
A map of all headers in the request to upgrade to websocket
|
String |
path()
The path the websocket is attempting to connect at
|
ServerWebSocket |
pause()
Pause the
ReadSupport . |
String |
query()
The query string passed on the websocket uri
|
ServerWebSocket |
reject()
Reject the WebSocket<p>
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.<p>
You might use this method, if for example you only want to accept websockets
with a particular path.
|
ServerWebSocket |
resume()
Resume reading.
|
ServerWebSocket |
setWriteQueueMaxSize(int maxSize)
Set the maximum size of the write queue to
maxSize . |
String |
uri() |
ServerWebSocket |
write(Buffer data)
Write some data to the stream.
|
ServerWebSocket |
writeFrame(WebSocketFrame frame) |
ServerWebSocket |
writeMessage(Buffer data)
Writes a (potentially large) piece of data as a websocket message - this may be split into multiple frames
if it is large.
|
binaryHandlerID, close, localAddress, remoteAddress, textHandlerID
writeQueueFull
ServerWebSocket exceptionHandler(Handler<Throwable> handler)
StreamBase
Set an exception handler.
exceptionHandler
in interface ReadStream<Buffer>
exceptionHandler
in interface StreamBase
exceptionHandler
in interface WebSocketBase
exceptionHandler
in interface WriteStream<Buffer>
ServerWebSocket handler(Handler<Buffer> handler)
ReadStream
Set a data handler. As data is read, the handler will be called with the data.
handler
in interface ReadStream<Buffer>
handler
in interface WebSocketBase
ServerWebSocket pause()
ReadStream
Pause the ReadSupport
. While it’s paused, no data will be sent to the dataHandler
pause
in interface ReadStream<Buffer>
pause
in interface WebSocketBase
ServerWebSocket resume()
ReadStream
Resume reading. If the ReadSupport
has been paused, reading will recommence on it.
resume
in interface ReadStream<Buffer>
resume
in interface WebSocketBase
ServerWebSocket endHandler(Handler<Void> endHandler)
ReadStream
Set an end handler. Once the stream has ended, and there is no more data to be read, this handler will be called.
endHandler
in interface ReadStream<Buffer>
endHandler
in interface WebSocketBase
ServerWebSocket write(Buffer data)
WriteStream
Write some data to the stream. The data is put on an internal write queue, and the write actually happens
asynchronously. To avoid running out of memory by putting too much on the write queue,
check the WriteStream.writeQueueFull()
method before writing. This is done automatically if using a Pump
.
write
in interface WebSocketBase
write
in interface WriteStream<Buffer>
ServerWebSocket setWriteQueueMaxSize(int maxSize)
WriteStream
Set the maximum size of the write queue to 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.
setWriteQueueMaxSize
in interface WebSocketBase
setWriteQueueMaxSize
in interface WriteStream<Buffer>
ServerWebSocket drainHandler(Handler<Void> handler)
WriteStream
Set a drain handler on the stream. If the write queue is full, then the handler will be called when the write
queue has been reduced to maxSize / 2. See Pump
for an example of this being used.
drainHandler
in interface WebSocketBase
drainHandler
in interface WriteStream<Buffer>
ServerWebSocket writeFrame(WebSocketFrame frame)
writeFrame
in interface WebSocketBase
ServerWebSocket writeMessage(Buffer data)
WebSocketBase
Writes a (potentially large) piece of data as a websocket message - this may be split into multiple frames if it is large.
writeMessage
in interface WebSocketBase
ServerWebSocket closeHandler(Handler<Void> handler)
WebSocketBase
Set a closed handler on the connection
closeHandler
in interface WebSocketBase
ServerWebSocket frameHandler(Handler<WebSocketFrame> handler)
WebSocketBase
Set a frame handler on the connection
frameHandler
in interface WebSocketBase
String uri()
String path()
The path the websocket is attempting to connect at
String query()
The query string passed on the websocket uri
MultiMap headers()
A map of all headers in the request to upgrade to websocket
ServerWebSocket reject()
Reject the WebSocket<p> 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.<p> You might use this method, if for example you only want to accept websockets with a particular path.
Copyright © 2014. All Rights Reserved.