public class ServerWebSocketImpl extends WebSocketImplBase implements ServerWebSocket
closed, closeHandler, conn, dataHandler, drainHandler, endHandler, exceptionHandler, frameHandler
Constructor and Description |
---|
ServerWebSocketImpl(VertxInternal vertx,
String uri,
String path,
String query,
MultiMap headers,
ConnectionBase conn,
boolean supportsContinuation,
Runnable connectRunnable,
int maxWebSocketFrameSize) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the WebSocket.
|
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> handler)
Set an end handler.
|
ServerWebSocket |
exceptionHandler(Handler<Throwable> handler)
Set an exception handler on the read stream.
|
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
ReadSupport . |
X509Certificate[] |
peerCertificateChain() |
String |
query() |
void |
reject()
Reject the WebSocket.
|
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 |
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
|
boolean |
writeQueueFull()
This will return
true if there are more bytes in the write queue than the value set using WriteStream.setWriteQueueMaxSize(int) |
binaryHandlerID, checkClosed, localAddress, remoteAddress, textHandlerID, writeBinaryFrameInternal, writeFrameInternal, writeMessageInternal, writePartialMessage, writeTextFrameInternal
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
binaryHandlerID, localAddress, remoteAddress, textHandlerID
public ServerWebSocketImpl(VertxInternal vertx, String uri, String path, String query, MultiMap headers, ConnectionBase conn, boolean supportsContinuation, Runnable connectRunnable, int maxWebSocketFrameSize)
public String uri()
uri
in interface ServerWebSocket
public String path()
path
in interface ServerWebSocket
public String query()
query
in interface ServerWebSocket
public MultiMap headers()
headers
in interface ServerWebSocket
public void reject()
ServerWebSocket
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 404 response code.
You might use this method, if for example you only want to accept WebSockets with a particular path.
reject
in interface ServerWebSocket
public X509Certificate[] peerCertificateChain() throws SSLPeerUnverifiedException
peerCertificateChain
in interface ServerWebSocket
SSLPeerUnverifiedException
- SSL peer's identity has not been verified.public void close()
WebSocketBase
close
in interface WebSocketBase
close
in class WebSocketImplBase
public ServerWebSocket handler(Handler<Buffer> handler)
ReadStream
handler
in interface ServerWebSocket
handler
in interface WebSocketBase
handler
in interface ReadStream<Buffer>
public ServerWebSocket endHandler(Handler<Void> handler)
ReadStream
endHandler
in interface ServerWebSocket
endHandler
in interface WebSocketBase
endHandler
in interface ReadStream<Buffer>
public ServerWebSocket exceptionHandler(Handler<Throwable> handler)
ReadStream
exceptionHandler
in interface ServerWebSocket
exceptionHandler
in interface WebSocketBase
exceptionHandler
in interface ReadStream<Buffer>
exceptionHandler
in interface StreamBase
exceptionHandler
in interface WriteStream<Buffer>
exceptionHandler
in class WebSocketImplBase
handler
- the exception handlerpublic ServerWebSocket closeHandler(Handler<Void> handler)
WebSocketBase
closeHandler
in interface ServerWebSocket
closeHandler
in interface WebSocketBase
handler
- the handlerpublic ServerWebSocket frameHandler(Handler<WebSocketFrame> handler)
WebSocketBase
frameHandler
in interface ServerWebSocket
frameHandler
in interface WebSocketBase
handler
- the handlerpublic ServerWebSocket pause()
ReadStream
ReadSupport
. While it's paused, no data will be sent to the dataHandler
pause
in interface ServerWebSocket
pause
in interface WebSocketBase
pause
in interface ReadStream<Buffer>
public ServerWebSocket resume()
ReadStream
ReadSupport
has been paused, reading will recommence on it.resume
in interface ServerWebSocket
resume
in interface WebSocketBase
resume
in interface ReadStream<Buffer>
public ServerWebSocket 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.setWriteQueueMaxSize
in interface ServerWebSocket
setWriteQueueMaxSize
in interface WebSocketBase
setWriteQueueMaxSize
in interface WriteStream<Buffer>
maxSize
- the max size of the write streampublic boolean writeQueueFull()
WriteStream
true
if there are more bytes in the write queue than the value set using WriteStream.setWriteQueueMaxSize(int)
writeQueueFull
in interface WriteStream<Buffer>
writeQueueFull
in class WebSocketImplBase
public ServerWebSocket write(Buffer data)
WriteStream
WriteStream.writeQueueFull()
method before writing. This is done automatically if using a Pump
.write
in interface ServerWebSocket
write
in interface WebSocketBase
write
in interface WriteStream<Buffer>
data
- the data to writepublic ServerWebSocket drainHandler(Handler<Void> handler)
WriteStream
Pump
for an example of this being used.drainHandler
in interface ServerWebSocket
drainHandler
in interface WebSocketBase
drainHandler
in interface WriteStream<Buffer>
handler
- the handlerpublic ServerWebSocket writeFrame(WebSocketFrame frame)
WebSocketBase
writeFrame
in interface ServerWebSocket
writeFrame
in interface WebSocketBase
frame
- the frame to writepublic ServerWebSocket writeFinalTextFrame(String text)
WebSocketBase
writeFinalTextFrame
in interface ServerWebSocket
writeFinalTextFrame
in interface WebSocketBase
text
- The text to writepublic ServerWebSocket writeFinalBinaryFrame(Buffer data)
WebSocketBase
writeFinalBinaryFrame
in interface ServerWebSocket
writeFinalBinaryFrame
in interface WebSocketBase
data
- The data to writepublic ServerWebSocket writeBinaryMessage(Buffer data)
WebSocketBase
writeBinaryMessage
in interface ServerWebSocket
writeBinaryMessage
in interface WebSocketBase
data
- the data to writeCopyright © 2015. All Rights Reserved.