public interface ServerWebSocket extends WebSocketBase
Instances of this class are passed into a HttpServer.websocketHandler(io.vertx.core.Handler<io.vertx.core.http.ServerWebSocket>) or provided
when a WebSocket handshake is manually HttpServerRequest.upgrade()ed.
| Modifier and Type | Method and Description |
|---|---|
void |
accept()
Accept the WebSocket and terminate the WebSocket handshake.
|
ServerWebSocket |
closeHandler(Handler<Void> handler)
Set a close handler.
|
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 on the read stream.
|
ServerWebSocket |
fetch(long amount)
Fetch the specified
amount of elements. |
ServerWebSocket |
frameHandler(Handler<WebSocketFrame> handler)
Set a frame handler on the connection.
|
ServerWebSocket |
handler(Handler<Buffer> handler)
Set a data handler.
|
MultiMap |
headers() |
String |
path() |
ServerWebSocket |
pause()
Pause the
ReadStream, it sets the buffer in fetch mode and clears the actual demand. |
X509Certificate[] |
peerCertificateChain()
Note: Java SE 5+ recommends to use javax.net.ssl.SSLSession#getPeerCertificates() instead of
of javax.net.ssl.SSLSession#getPeerCertificateChain() which this method is based on.
|
String |
query() |
void |
reject()
Reject the WebSocket.
|
void |
reject(int status)
Like
reject() but with a status. |
ServerWebSocket |
resume()
Resume reading, and sets the buffer in
flowing mode. |
ServerWebSocket |
setWriteQueueMaxSize(int maxSize)
Set the maximum size of the write queue to
maxSize. |
SSLSession |
sslSession() |
String |
uri() |
ServerWebSocket |
write(Buffer data)
Write some data to the stream.
|
ServerWebSocket |
writeBinaryMessage(Buffer data)
Writes a (potentially large) piece of binary data to the connection.
|
ServerWebSocket |
writeFinalBinaryFrame(Buffer data)
Write a final WebSocket binary frame to the connection
|
ServerWebSocket |
writeFinalTextFrame(String text)
Write a final WebSocket text frame to the connection
|
ServerWebSocket |
writeFrame(WebSocketFrame frame)
Write a WebSocket frame to the connection
|
binaryHandlerID, binaryMessageHandler, close, close, close, end, isSsl, localAddress, pongHandler, remoteAddress, subProtocol, textHandlerID, textMessageHandler, writePing, writePong, writeTextMessageend, writeQueueFullServerWebSocket exceptionHandler(Handler<Throwable> handler)
ReadStreamexceptionHandler in interface ReadStream<Buffer>exceptionHandler in interface StreamBaseexceptionHandler in interface WebSocketBaseexceptionHandler in interface WriteStream<Buffer>handler - the exception handlerServerWebSocket handler(Handler<Buffer> handler)
ReadStreamhandler in interface ReadStream<Buffer>handler in interface WebSocketBaseServerWebSocket pause()
ReadStreamReadStream, it sets the buffer in fetch mode and clears the actual demand.
While it's paused, no data will be sent to the data handler.
pause in interface ReadStream<Buffer>pause in interface WebSocketBaseServerWebSocket resume()
ReadStreamflowing mode.
If the ReadStream has been paused, reading will recommence on it.resume in interface ReadStream<Buffer>resume in interface WebSocketBaseServerWebSocket fetch(long amount)
ReadStreamamount of elements. If the ReadStream has been paused, reading will
recommence with the specified amount of items, otherwise the specified amount will
be added to the current stream demand.fetch in interface ReadStream<Buffer>fetch in interface WebSocketBaseServerWebSocket endHandler(Handler<Void> endHandler)
ReadStreamendHandler in interface ReadStream<Buffer>endHandler in interface WebSocketBaseServerWebSocket write(Buffer data)
WriteStreamWriteStream.writeQueueFull() method before writing. This is done automatically if using a Pump.write in interface WebSocketBasewrite in interface WriteStream<Buffer>data - the data to writeServerWebSocket setWriteQueueMaxSize(int maxSize)
WriteStreammaxSize. You will still be able to write to the stream even
if there is more than maxSize items in the write queue. This is used as an indicator by classes such as
Pump to provide flow control.
The value is defined by the implementation of the stream, e.g in bytes for a
NetSocket, the number of Message for a
MessageProducer, etc...setWriteQueueMaxSize in interface WebSocketBasesetWriteQueueMaxSize in interface WriteStream<Buffer>maxSize - the max size of the write streamServerWebSocket drainHandler(Handler<Void> handler)
WriteStreamPump for an example of this being used.
The stream implementation defines when the drain handler, for example it could be when the queue size has been
reduced to maxSize / 2.drainHandler in interface WebSocketBasedrainHandler in interface WriteStream<Buffer>handler - the handlerServerWebSocket writeFrame(WebSocketFrame frame)
WebSocketBasewriteFrame in interface WebSocketBaseframe - the frame to writeServerWebSocket writeFinalTextFrame(String text)
WebSocketBasewriteFinalTextFrame in interface WebSocketBasetext - The text to writeServerWebSocket writeFinalBinaryFrame(Buffer data)
WebSocketBasewriteFinalBinaryFrame in interface WebSocketBasedata - The data to writeServerWebSocket writeBinaryMessage(Buffer data)
WebSocketBasewriteBinaryMessage in interface WebSocketBasedata - the data to writeServerWebSocket closeHandler(Handler<Void> handler)
WebSocketBasecloseHandler in interface WebSocketBasehandler - the handlerServerWebSocket frameHandler(Handler<WebSocketFrame> handler)
WebSocketBaseframeHandler in interface WebSocketBasehandler - the handlerString uri()
String path()
String query()
MultiMap headers()
void accept()
void reject()
Calling this method from the websocket handler when it is first passed to you gives you the opportunity to reject the websocket, which will cause the websocket handshake to fail by returning a 502 response code.
You might use this method, if for example you only want to accept WebSockets with a particular path.
void reject(int status)
reject() but with a status.SSLSession sslSession()
sslSession in interface WebSocketBaseSSLSessionX509Certificate[] peerCertificateChain() throws SSLPeerUnverifiedException
sslSession() to
access that method.peerCertificateChain in interface WebSocketBaseSSLPeerUnverifiedException - SSL peer's identity has not been verified.SSLSession.getPeerCertificateChain(),
sslSession()Copyright © 2018 Eclipse. All rights reserved.