Represents an HTML 5 Websocket

Instances of this class are created and provided to the handler of an HttpClient when a successful websocket connect attempt occurs.

On the server side, the subclass ServerWebSocket is used instead.

It provides access to both ReadStream and WriteStream so it can be used with Pump to pump data with flow control.

Instances of this class are not thread-safe

Initializer
WebSocketBase(WebSocketBase<out Object> delegate)
Attributes
binaryHandlerIdshared String binaryHandlerId= delegate.binaryHandlerID()

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

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.

localAddressshared SocketAddress localAddress

Return the local address for this socket

readStreamshared ReadStream readStream
remoteAddressshared SocketAddress remoteAddress

Return the remote address for this socket

textHandlerIDshared String textHandlerID= delegate.textHandlerID()

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.

writeStreamshared WriteStream writeStream
Inherited Attributes
Attributes inherited from: Object
hash, string
Methods
closeshared void close()

Close the websocket

closeHandlershared Promise<Anything> closeHandler()
frameHandlershared WebSocketBase frameHandler(void onFrame(WebSocketFrame frame))

Set a frame handler on the connection

writeBinaryFrameshared WebSocketBase writeBinaryFrame(Buffer buffer)

Write data to the websocket as a binary frame

writeTextFrameshared WebSocketBase writeTextFrame(String str)

Write str to the websocket as a text frame

Inherited Methods
Methods inherited from: Object
equals