Represents a server side WebSocket.

Instances of this class are passed into a websocketHandler or provided when a WebSocket handshake is manually upgradeed.

no subtypes hierarchy

Initializer
ServerWebSocket(ServerWebSocket unknown)
Inherited Attributes
Attributes inherited from: Object
hash, string
Methods
binaryHandlerIDshared actual default String binaryHandlerID()

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.

closeshared actual default void close()

Close the WebSocket.

closeHandlershared actual default ServerWebSocket closeHandler(Anything()? handler)

Set a close handler. This will be called when the WebSocket is closed.

drainHandlershared actual default ServerWebSocket drainHandler(Anything()? handler)

Set a drain handler on the stream. If the write queue is full, then the handler will be called when the write queue has been reduced to maxSize / 2. See Pump for an example of this being used.

endshared actual default void end()

Calls close

endshared actual default void end(Buffer t)

Same as end but writes some data to the stream before ending.

endHandlershared actual default ServerWebSocket endHandler(Anything()? endHandler)

Set an end handler. Once the stream has ended, and there is no more data to be read, this handler will be called.

exceptionHandlershared actual default ServerWebSocket exceptionHandler(Anything(Throwable)? handler)

Set an exception handler.

frameHandlershared actual default ServerWebSocket frameHandler(Anything(WebSocketFrame)? handler)

Set a frame handler on the connection. This handler will be called when frames are read on the connection.

handlershared actual default ServerWebSocket handler(Anything(Buffer)? handler)

Set a data handler. As data is read, the handler will be called with the data.

headersshared default MultiMap headers()

@return the headers in the WebSocket handshake

localAddressshared actual default SocketAddress localAddress()

@return the local address for this socket

pathshared default String path()

@return the WebSocket handshake path.

pauseshared actual default ServerWebSocket pause()

Pause the ReadSupport. While it's paused, no data will be sent to the dataHandler

queryshared default String? query()

@return the WebSocket handshake query string.

rejectshared default void reject()

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

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

remoteAddressshared actual default SocketAddress remoteAddress()

@return the remote address for this socket

resumeshared actual default ServerWebSocket resume()

Resume reading. If the ReadSupport has been paused, reading will recommence on it.

setWriteQueueMaxSizeshared actual default ServerWebSocket setWriteQueueMaxSize(Integer maxSize)

Set the maximum size of the write queue to 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.

textHandlerIDshared actual default String 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.

urishared default String uri()
writeshared actual default ServerWebSocket write(Buffer data)
writeBinaryMessageshared actual default ServerWebSocket writeBinaryMessage(Buffer data)

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

writeFinalBinaryFrameshared actual default ServerWebSocket writeFinalBinaryFrame(Buffer data)

Write a final WebSocket binary frame to the connection

writeFinalTextFrameshared actual default ServerWebSocket writeFinalTextFrame(String text)

Write a final WebSocket text frame to the connection

writeFrameshared actual default ServerWebSocket writeFrame(WebSocketFrame frame)

Write a WebSocket frame to the connection

writeQueueFullshared actual default Boolean writeQueueFull()

This will return true if there are more bytes in the write queue than the value set using setWriteQueueMaxSize

Inherited Methods
Methods inherited from: Object
equals
Methods inherited from: ReadStream<T>
Methods inherited from: StreamBase
Methods inherited from: WebSocketBase
Methods inherited from: WriteStream<T>