vertx / io.vertx.rxjava.core.http / ServerWebSocket

ServerWebSocket

open class ServerWebSocket : WebSocketBase

Represents a server side WebSocket.

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

NOTE: This class has been automatically generated from the io.vertx.core.http.ServerWebSocket non RX-ified interface using Vert.x codegen.

Constructors

<init>

ServerWebSocket(delegate: ServerWebSocket)

Properties

__TYPE_ARG

static val __TYPE_ARG: TypeArg<ServerWebSocket>

Functions

accept

open 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.

binaryHandlerID

open fun binaryHandlerID(): String

When a Websocket is created it automatically registers an event handler with the event bus - the ID of that handler is given by this method.

Given this ID, a different event loop can send a binary frame to that event handler using the event bus and that buffer will be received by this instance in its own event loop and written to the underlying connection. This allows you to write data to other WebSockets which are owned by different event loops.

binaryMessageHandler

open fun binaryMessageHandler(handler: Handler<Buffer>): WebSocketBase

Set a binary message handler on the connection. This handler serves a similar purpose to io.vertx.rxjava.core.http.ServerWebSocket#handler except that if a message comes into the socket in multiple frames, the data from the frames will be aggregated into a single buffer before calling the handler (using io.vertx.rxjava.core.http.WebSocketFrame#isFinal to find the boundaries).

close

open fun close(): Unit

Close the WebSocket.

open fun close(statusCode: Short): Unit
open fun close(statusCode: Short, reason: String): Unit

closeHandler

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

drainHandler

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

end

open fun end(t: Buffer): Unit

Same as io.vertx.rxjava.core.http.WebSocketBase#end but writes some data to the stream before ending.

open fun end(): Unit

Calls io.vertx.rxjava.core.http.WebSocketBase#close

endHandler

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

equals

open fun equals(other: Any?): Boolean

exceptionHandler

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

frameHandler

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

getDelegate

open fun getDelegate(): ServerWebSocket

handler

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

hashCode

open fun hashCode(): Int

headers

open fun headers(): MultiMap

isSsl

open fun isSsl(): Boolean

localAddress

open fun localAddress(): SocketAddress

newInstance

open static fun newInstance(arg: ServerWebSocket): ServerWebSocket

path

open fun path(): String

pause

open fun pause(): ServerWebSocket

pongHandler

open fun pongHandler(handler: Handler<Buffer>): WebSocketBase

Set a pong message handler on the connection. This handler will be invoked every time a pong message is received on the server, and can be used by both clients and servers since the RFC 6455 Sections 5.5.2 and 5.5.3 do not specify whether the client or server sends a ping.

Pong frames may be at most 125 bytes (octets).

There is no ping handler since pings should immediately be responded to with a pong with identical content

Pong frames may be received unsolicited.

query

open fun query(): String

reject

open 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 response code.

You might use this method, if for example you only want to accept WebSockets with a particular path.

open fun reject(status: Int): Unit

Like io.vertx.rxjava.core.http.ServerWebSocket#reject but with a status.

remoteAddress

open fun remoteAddress(): SocketAddress

resume

open fun resume(): ServerWebSocket

setWriteQueueMaxSize

open fun setWriteQueueMaxSize(maxSize: Int): ServerWebSocket

subProtocol

open fun subProtocol(): String

Returns the websocket sub protocol selected by the websocket handshake. On the server, the value will be null when the handler receives the websocket callback as the handshake will not be completed yet.

textHandlerID

open fun textHandlerID(): String

When a Websocket is created it automatically registers an event handler with the eventbus, the ID of that handler is given by textHandlerID.

Given this ID, a different event loop can send a text frame to that event handler using the event bus and that buffer will be received by this instance in its own event loop and written to the underlying connection. This allows you to write data to other WebSockets which are owned by different event loops.

textMessageHandler

open fun textMessageHandler(handler: Handler<String>): WebSocketBase

Set a text message handler on the connection. This handler will be called similar to the , but the buffer will be converted to a String first

toObservable

open fun toObservable(): Observable<Buffer>

toString

open fun toString(): String

uri

open fun uri(): String

write

open fun write(data: Buffer): ServerWebSocket

writeBinaryMessage

open fun writeBinaryMessage(data: Buffer): ServerWebSocket

writeFinalBinaryFrame

open fun writeFinalBinaryFrame(data: Buffer): ServerWebSocket

writeFinalTextFrame

open fun writeFinalTextFrame(text: String): ServerWebSocket

writeFrame

open fun writeFrame(frame: WebSocketFrame): ServerWebSocket

writePing

open fun writePing(data: Buffer): WebSocketBase

Writes a ping to the connection. This will be written in a single frame. Ping frames may be at most 125 bytes (octets).

This method should not be used to write application data and should only be used for implementing a keep alive or to ensure the client is still responsive, see RFC 6455 Section 5.5.2.

There is no pingHandler because RFC 6455 section 5.5.2 clearly states that the only response to a ping is a pong with identical contents.

writePong

open fun writePong(data: Buffer): WebSocketBase

Writes a pong to the connection. This will be written in a single frame. Pong frames may be at most 125 bytes (octets).

This method should not be used to write application data and should only be used for implementing a keep alive or to ensure the client is still responsive, see RFC 6455 Section 5.5.2.

There is no need to manually write a Pong, as the server and client both handle responding to a ping with a pong automatically and this is exposed to users.RFC 6455 Section 5.5.3 states that pongs may be sent unsolicited in order to implement a one way heartbeat.

writeQueueFull

open fun writeQueueFull(): Boolean

This will return true if there are more bytes in the write queue than the value set using io.vertx.rxjava.core.http.ServerWebSocket#setWriteQueueMaxSize

writeTextMessage

open fun writeTextMessage(text: String): WebSocketBase

Writes a (potentially large) piece of text data to the connection. This data might be written as multiple frames if it exceeds the maximum WebSocket frame size.