Represents a server side WebSocket.
Instances of this class are passed into a websocketHandler or provided when a WebSocket handshake is manually upgradeed.
Anything
ServerWebSocket
Basic
Identifiable
Object
Anything
no subtypes hierarchy
Initializer |
ServerWebSocket(ServerWebSocket unknown) |
Inherited Attributes |
Attributes inherited from: Object hash , string |
Methods | |
accept | shared default void accept() 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 | shared actual default String binaryHandlerID() When a 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. Refines WebSocketBase.binaryHandlerID |
binaryMessageHandler | shared actual default WebSocketBase binaryMessageHandler(Anything(Buffer)? handler) Set a binary message handler on the connection. This handler serves a similar purpose to 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 isFinal to find the boundaries). Parameters:
|
close | shared actual default void close() Close the WebSocket. Refines WebSocketBase.close |
closeHandler | shared actual default ServerWebSocket closeHandler(Anything()? handler) Set a close handler. This will be called when the WebSocket is closed. Refines WebSocketBase.closeHandler |
drainHandler | shared 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 is ready to accept buffers again. See Pump for an example of this being used. The stream implementation defines when the drain handler, for example it could be when the queue size has been reduced tomaxSize / 2 .
Refines WriteStream.drainHandler |
end | shared actual default void end() Calls close Refines WriteStream.end |
end | shared actual default void end(Buffer t) Same as end but writes some data to the stream before ending. Refines WebSocketBase.end |
endHandler | shared 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. Refines ReadStream.endHandler |
exceptionHandler | shared actual default ServerWebSocket exceptionHandler(Anything(Throwable)? handler) Set an exception handler. Refines StreamBase.exceptionHandler |
frameHandler | shared 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. Refines WebSocketBase.frameHandler |
handler | shared actual default ServerWebSocket handler(Anything(Buffer)? handler) Set a data handler. As data is read, the handler will be called with the data. Refines ReadStream.handler |
headers | shared default MultiMap headers() |
isSsl | shared actual default Boolean isSsl() Refines WebSocketBase.isSsl |
localAddress | shared actual default SocketAddress localAddress() Refines WebSocketBase.localAddress |
path | shared default String path() |
pause | shared actual default ServerWebSocket pause() Pause the Refines ReadStream.pause |
pongHandler | shared actual default WebSocketBase pongHandler(Anything(Buffer)? handler) 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. Parameters:
Refines WebSocketBase.pongHandler |
query | shared default String? query() |
reject | shared 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 response code. You might use this method, if for example you only want to accept WebSockets with a particular path. |
reject | shared default void reject(Integer status) Like reject but with a |
remoteAddress | shared actual default SocketAddress remoteAddress() Refines WebSocketBase.remoteAddress |
resume | shared actual default ServerWebSocket resume() Resume reading. If the Refines ReadStream.resume |
setWriteQueueMaxSize | shared actual default ServerWebSocket setWriteQueueMaxSize(Integer maxSize) Set the maximum size of the write queue to Refines WriteStream.setWriteQueueMaxSize |
subProtocol | shared actual default String subProtocol() Returns the websocket sub protocol selected by the websocket handshake. On the server, the value will benull when the handler receives the websocket callback as the
handshake will not be completed yet.
Refines WebSocketBase.subProtocol |
textHandlerID | shared actual default String textHandlerID() When a 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. Refines WebSocketBase.textHandlerID |
textMessageHandler | shared actual default WebSocketBase textMessageHandler(Anything(String)? handler) 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 Parameters:
Refines WebSocketBase.textMessageHandler |
uri | shared default String uri() |
write | shared actual default ServerWebSocket write(Buffer data) Refines WebSocketBase.write |
writeBinaryMessage | shared 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. Refines WebSocketBase.writeBinaryMessage |
writeFinalBinaryFrame | shared actual default ServerWebSocket writeFinalBinaryFrame(Buffer data) Write a final WebSocket binary frame to the connection |
writeFinalTextFrame | shared actual default ServerWebSocket writeFinalTextFrame(String text) Write a final WebSocket text frame to the connection |
writeFrame | shared actual default ServerWebSocket writeFrame(WebSocketFrame frame) Write a WebSocket frame to the connection Refines WebSocketBase.writeFrame |
writePing | shared actual default WebSocketBase writePing(Buffer data) 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. Parameters:
Refines WebSocketBase.writePing |
writePong | shared actual default WebSocketBase writePong(Buffer data) 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. Parameters:
Refines WebSocketBase.writePong |
writeQueueFull | shared actual default Boolean writeQueueFull() This will return Refines WriteStream.writeQueueFull |
writeTextMessage | shared actual default WebSocketBase writeTextMessage(String text) 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. Parameters:
Refines WebSocketBase.writeTextMessage |
Inherited Methods |
Methods inherited from: Object equals |
Methods inherited from: ReadStream<T> |
Methods inherited from: StreamBase |
Methods inherited from: WebSocketBase binaryHandlerID() , binaryMessageHandler() , close() , closeHandler() , drainHandler() , end() , endHandler() , exceptionHandler() , frameHandler() , handler() , isSsl() , localAddress() , pause() , pongHandler() , remoteAddress() , resume() , setWriteQueueMaxSize() , subProtocol() , textHandlerID() , textMessageHandler() , write() , writeBinaryMessage() , writeFinalBinaryFrame() , writeFinalTextFrame() , writeFrame() , writePing() , writePong() , writeQueueFull() , writeTextMessage() |
Methods inherited from: WriteStream<T> |