SocketBuilder

A builder class used to configure WebSocket server sessions.

This class allows for the setup of WebSocket event handlers such as connection, message reception, and disconnection. It also provides middleware support to process events before passing to the handler.

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard
fun onClose(block: suspend (String) -> Unit): SocketBuilder

Sets the callback to be invoked when the WebSocket connection is closed.

Link copied to clipboard
fun onConnect(block: suspend SocketSession.() -> Unit): SocketBuilder

Sets the callback to be invoked when a WebSocket connection is established.

Link copied to clipboard
fun onMessage(block: suspend SocketSession.(String) -> Unit): SocketBuilder

Sets the callback to be invoked when a message is received through the WebSocket connection.

Link copied to clipboard
fun use(block: suspend SocketSession.() -> Unit): SocketBuilder

Adds middleware to the WebSocket session.