WebsocketConnection

class WebsocketConnection(pointer: <Error class: unknown class><<Error class: unknown class>>)

The WebSocket Protocol

Provides support for the WebSocket protocol.

To connect to a WebSocket server, create a class@Session and call method@Session.websocket_connect_async. To accept WebSocket connections, create a class@Server and add a handler to it with method@Server.add_websocket_handler.

(Lower-level support is available via func@websocket_client_prepare_handshake and func@websocket_client_verify_handshake, for handling the client side of the WebSocket handshake, and func@websocket_server_process_handshake for handling the server side.)

#SoupWebsocketConnection handles the details of WebSocket communication. You can use method@WebsocketConnection.send_text and method@WebsocketConnection.send_binary to send data, and the signal@WebsocketConnection::message signal to receive data. (#SoupWebsocketConnection currently only supports asynchronous I/O.)

Skipped during bindings generation

  • parameter code: gushort

  • method get_close_code: Return type gushort is unsupported

  • parameter data: Array parameter of type guint8 is not supported

Constructors

Link copied to clipboard
constructor(stream: <Error class: unknown class>, uri: <Error class: unknown class>, type: WebsocketConnectionType, origin: String? = null, protocol: String? = null, extensions: <Error class: unknown class>)

Creates a #SoupWebsocketConnection on @stream with the given active @extensions.

constructor(pointer: <Error class: unknown class><<Error class: unknown class>>)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The type of connection (client/server).

Link copied to clipboard
val extensions: <Error class: unknown class>

List of class@WebsocketExtension objects that are active in the connection.

Link copied to clipboard
val ioStream: <Error class: unknown class>

The underlying IO stream the WebSocket is communicating over.

Link copied to clipboard
var keepaliveInterval: <Error class: unknown class>

Interval in seconds on when to send a ping message which will serve as a keepalive message.

Link copied to clipboard
var keepalivePongTimeout: <Error class: unknown class>

Timeout in seconds for when the absence of a pong from a keepalive ping is assumed to be caused by a faulty connection. The WebSocket will be transitioned to a closed state when this happens.

Link copied to clipboard
var maxIncomingPayloadSize: <Error class: unknown class>

The maximum payload size for incoming packets.

Link copied to clipboard

The client's Origin.

Link copied to clipboard

The chosen protocol, or null if a protocol was not agreed upon.

Link copied to clipboard
val soupWebsocketConnectionPointer: <Error class: unknown class><<Error class: unknown class>>
Link copied to clipboard

The current state of the WebSocket.

Link copied to clipboard
val uri: <Error class: unknown class>

The URI of the WebSocket.

Functions

Link copied to clipboard
fun connectClosed(connectFlags: <Error class: unknown class> = ConnectFlags(0u), handler: () -> Unit): <Error class: unknown class>

Emitted when the connection has completely closed.

Link copied to clipboard
fun connectClosing(connectFlags: <Error class: unknown class> = ConnectFlags(0u), handler: () -> Unit): <Error class: unknown class>

This signal will be emitted during an orderly close.

Link copied to clipboard
fun connectError(connectFlags: <Error class: unknown class> = ConnectFlags(0u), handler: (<Error class: unknown class>) -> Unit): <Error class: unknown class>

Emitted when an error occurred on the WebSocket.

Link copied to clipboard
fun connectMessage(connectFlags: <Error class: unknown class> = ConnectFlags(0u), handler: (<Error class: unknown class>, <Error class: unknown class>) -> Unit): <Error class: unknown class>

Emitted when we receive a message from the peer.

Link copied to clipboard
fun connectPong(connectFlags: <Error class: unknown class> = ConnectFlags(0u), handler: (<Error class: unknown class>) -> Unit): <Error class: unknown class>

Emitted when we receive a Pong frame (solicited or unsolicited) from the peer.

Link copied to clipboard

Get the close data received from the WebSocket peer.

Link copied to clipboard
fun sendMessage(type: WebsocketDataType, message: <Error class: unknown class>)

Send a message of the given @type to the peer. Note that this method, allows to send text messages containing null characters.

Link copied to clipboard
fun sendText(text: String)

Send a null-terminated text (UTF-8) message to the peer.