Soup.WebsocketConnection
Description: Reference for Soup.WebsocketConnection

### Class

# SoupWebsocketConnection

#### Description [src]

    final class Soup.WebsocketConnection : GObject.Object {
      /* No available fields */
    }

The WebSocket Protocol

Provides support for the WebSocket protocol.

To connect to a WebSocket server, create a `SoupSession` and call `soup_session_websocket_connect_async()`. To accept WebSocket connections, create a `SoupServer` and add a handler to it with `soup_server_add_websocket_handler()`.

(Lower-level support is available via `soup_websocket_client_prepare_handshake()` and `soup_websocket_client_verify_handshake()`, for handling the client side of the WebSocket handshake, and `soup_websocket_server_process_handshake()` for handling the server side.)

`SoupWebsocketConnection` handles the details of WebSocket communication. You can use `soup_websocket_connection_send_text()` and `soup_websocket_connection_send_binary()` to send data, and the `SoupWebsocketConnection::message` signal to receive data. (`SoupWebsocketConnection` currently only supports asynchronous I/O.)

#### Hierarchy

#### Ancestors

- GObject

#### Constructors

###### soup_websocket_connection_new

Creates a `SoupWebsocketConnection` on `stream` with the given active `extensions`.

#### Instance methods

###### soup_websocket_connection_close

Close the connection in an orderly fashion.

###### soup_websocket_connection_get_close_code

Get the close code received from the WebSocket peer.

###### soup_websocket_connection_get_close_data

Get the close data received from the WebSocket peer.

###### soup_websocket_connection_get_connection_type

Get the connection type (client/server) of the connection.

###### soup_websocket_connection_get_extensions

Get the extensions chosen via negotiation with the peer.

###### soup_websocket_connection_get_io_stream

Get the I/O stream the WebSocket is communicating over.

###### soup_websocket_connection_get_keepalive_interval

Gets the keepalive interval in seconds or 0 if disabled.

###### soup_websocket_connection_get_max_incoming_payload_size

Gets the maximum payload size allowed for incoming packets.

###### soup_websocket_connection_get_origin

Get the origin of the WebSocket.

###### soup_websocket_connection_get_protocol

Get the protocol chosen via negotiation with the peer.

###### soup_websocket_connection_get_state

Get the current state of the WebSocket.

###### soup_websocket_connection_get_uri

Get the URI of the WebSocket.

###### soup_websocket_connection_send_binary

Send a binary message to the peer.

###### soup_websocket_connection_send_message

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

###### soup_websocket_connection_send_text

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

###### soup_websocket_connection_set_keepalive_interval

Sets the interval in seconds on when to send a ping message which will serve as a keepalive message.

###### soup_websocket_connection_set_max_incoming_payload_size

Sets the maximum payload size allowed for incoming packets.

##### Methods inherited from GObject (43)

Please see GObject for a full list of methods.

#### Properties

###### Soup.WebsocketConnection:connection-type

The type of connection (client/server).

###### Soup.WebsocketConnection:extensions

List of `SoupWebsocketExtension` objects that are active in the connection.

###### Soup.WebsocketConnection:io-stream

The underlying IO stream the WebSocket is communicating over.

###### Soup.WebsocketConnection:keepalive-interval

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

###### Soup.WebsocketConnection:max-incoming-payload-size

The maximum payload size for incoming packets.

###### Soup.WebsocketConnection:origin

The client’s Origin.

###### Soup.WebsocketConnection:protocol

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

###### Soup.WebsocketConnection:state

The current state of the WebSocket.

###### Soup.WebsocketConnection:uri

The URI of the WebSocket.

#### Signals

###### Soup.WebsocketConnection::closed

Emitted when the connection has completely closed.

###### Soup.WebsocketConnection::closing

This signal will be emitted during an orderly close.

###### Soup.WebsocketConnection::error

Emitted when an error occurred on the WebSocket.

###### Soup.WebsocketConnection::message

Emitted when we receive a message from the peer.

###### Soup.WebsocketConnection::pong

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

##### Signals inherited from GObject (1)

###### GObject::notify

The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

#### Class structure

    struct SoupWebsocketConnectionClass {
      GObjectClass parent_class;

    }

The abstract base class for `SoupWebsocketConnection`.

###### Class members

`parent_class: GObjectClass`
  No description available.