vertx / io.vertx.core.http / ServerWebSocket

ServerWebSocket

interface ServerWebSocket : WebSocketBase

Represents a server side WebSocket.

Instances of this class are passed into a io.vertx.core.http.HttpServer#websocketHandler or provided when a WebSocket handshake is manually HttpServerRequest#upgradeed.

Author
Tim Fox

Functions

accept

abstract fun accept(): Unit

Accept the WebSocket and terminate the WebSocket handshake. This method should be called from the websocket handler to explicitely accept the websocker and terminate the WebSocket handshake.

closeHandler

abstract fun closeHandler(handler: Handler<Void>): ServerWebSocket

drainHandler

abstract fun drainHandler(handler: Handler<Void>): ServerWebSocket

endHandler

abstract fun endHandler(endHandler: Handler<Void>): ServerWebSocket

exceptionHandler

abstract fun exceptionHandler(handler: Handler<Throwable>): ServerWebSocket

frameHandler

abstract fun frameHandler(handler: Handler<WebSocketFrame>): ServerWebSocket

handler

abstract fun handler(handler: Handler<Buffer>): ServerWebSocket

headers

abstract fun headers(): MultiMap

path

abstract fun path(): String

pause

abstract fun pause(): ServerWebSocket

peerCertificateChain

abstract fun peerCertificateChain(): Array<X509Certificate>

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. Use #sslSession() to access that method.

query

abstract fun query(): String

reject

abstract fun reject(): Unit

Reject the WebSocket.

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.

abstract fun reject(status: Int): Unit

Like #reject() but with a status.

resume

abstract fun resume(): ServerWebSocket

setWriteQueueMaxSize

abstract fun setWriteQueueMaxSize(maxSize: Int): ServerWebSocket

sslSession

abstract fun sslSession(): SSLSession

uri

abstract fun uri(): String

write

abstract fun write(data: Buffer): ServerWebSocket

writeBinaryMessage

abstract fun writeBinaryMessage(data: Buffer): ServerWebSocket

writeFinalBinaryFrame

abstract fun writeFinalBinaryFrame(data: Buffer): ServerWebSocket

writeFinalTextFrame

abstract fun writeFinalTextFrame(text: String): ServerWebSocket

writeFrame

abstract fun writeFrame(frame: WebSocketFrame): ServerWebSocket