### Method

# Soup Session websocket_connect_async

#### Declaration [src]

    void
    soup_session_websocket_connect_async (
      SoupSession* session,
      SoupMessage* msg,
      const char* origin,
      char** protocols,
      int io_priority,
      GCancellable* cancellable,
      GAsyncReadyCallback callback,
      gpointer user_data
    )

#### Description [src]

Asynchronously creates a `SoupWebsocketConnection` to communicate with a remote server.

All necessary WebSocket-related headers will be added to `msg`, and it will then be sent and asynchronously processed normally (including handling of redirection and HTTP authentication).

If the server returns “101 Switching Protocols”, then `msg`‘s status code and response headers will be updated, and then the WebSocket handshake will be completed. On success, `soup_session_websocket_connect_finish()` will return a new `SoupWebsocketConnection`. On failure it will return a `GError`.

If the server returns a status other than “101 Switching Protocols”, then `msg` will contain the complete response headers and body from the server’s response, and `soup_session_websocket_connect_finish()` will return `SOUP_WEBSOCKET_ERROR_NOT_WEBSOCKET`.

#### Parameters

`msg` | `SoupMessage`
| `SoupMessage` indicating the WebSocket server to connect to.
| The data is owned by the caller of the function.
`origin` | `const char*`
| Origin of the connection.
| The argument can be `NULL`.
| The data is owned by the caller of the function.
| The value is a NUL terminated UTF-8 string.
`protocols` | An array of `char*`
| A `NULL`-terminated array of protocols supported.
| The argument can be `NULL`.
| The array must be `NULL`-terminated.
| The data is owned by the caller of the function.
| Each element is a NUL terminated UTF-8 string.
`io_priority` | `int`
| The I/O priority of the request.
`cancellable` | `GCancellable`
| A `GCancellable`.
| The argument can be `NULL`.
| The data is owned by the caller of the function.
`callback` | `GAsyncReadyCallback`
| The callback to invoke.
| The argument can be `NULL`.
`user_data` | `gpointer`
| Data for `callback`.
| The argument can be `NULL`.
| The data is owned by the caller of the function.