summaryrefslogtreecommitdiff
path: root/examples/websockets/doc/qmlwebsocketclient.qdoc
blob: b3da626860faade4dbb60e513b58a9ea4b9afc8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

/*!
    \example qmlwebsocketclient
    \title QML WebSocket Client
    \examplecategory {Networking}
    \ingroup qtwebsockets-examples
    \brief Explains how to write a QML WebSocket client example.

    The QML WebSocket Client example creates a secure and an
    insecure \l {Qt WebSockets}{WebSocket} connection to an echo
    server, using the QML API, and alternates between opening
    connections and closing them. Every time a connection has
    been opened, it sends a message.

    \image qmlwebsocketclient-example.webp QML WebSocket Client GUI

    This example opens a window with a welcome message. Every time
    the window is clicked on, it alternates between opening and
    closing two connections to an external echo server. The echo
    server used is at ws.ifelse.io, and an Internet connection is
    necessary for the example to work. Also TLS must be enabled for
    the secure connection to work. When the connection is opened or
    closed, the statusChanged signal is handled by the
    onStatusChanged handler. Every time the socket is opened, a
    message is sent, and every time the socket is closed, a message
    is logged in the window. In addition, there is an
    onTextMessageReceived handler that logs to the window the
    messages received from the server.
*/