1// Copyright (C) 2019 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QQMLDEBUGCONNECTION_P_H
5#define QQMLDEBUGCONNECTION_P_H
6
7#include <QtCore/qobject.h>
8#include <QtNetwork/qabstractsocket.h>
9#include <QtCore/private/qglobal_p.h>
10
11//
12// W A R N I N G
13// -------------
14//
15// This file is not part of the Qt API. It exists purely as an
16// implementation detail. This header file may change from version to
17// version without notice, or even be removed.
18//
19// We mean it.
20//
21
22QT_BEGIN_NAMESPACE
23
24class QQmlDebugClient;
25class QQmlDebugConnectionPrivate;
26class QQmlDebugConnection : public QObject
27{
28 Q_OBJECT
29 Q_DECLARE_PRIVATE(QQmlDebugConnection)
30public:
31 QQmlDebugConnection(QObject *parent = nullptr);
32 ~QQmlDebugConnection();
33
34 void connectToHost(const QString &hostName, quint16 port);
35 void startLocalServer(const QString &fileName);
36
37 int currentDataStreamVersion() const;
38 void setMaximumDataStreamVersion(int maximumVersion);
39
40 bool isConnected() const;
41 bool isConnecting() const;
42
43 void close();
44 bool waitForConnected(int msecs = 30000);
45
46 QQmlDebugClient *client(const QString &name) const;
47 bool addClient(const QString &name, QQmlDebugClient *client);
48 bool removeClient(const QString &name);
49
50 float serviceVersion(const QString &serviceName) const;
51 bool sendMessage(const QString &name, const QByteArray &message);
52
53Q_SIGNALS:
54 void connected();
55 void disconnected();
56 void socketError(QAbstractSocket::SocketError socketError);
57 void socketStateChanged(QAbstractSocket::SocketState socketState);
58
59private:
60 void newConnection();
61 void socketConnected();
62 void socketDisconnected();
63 void protocolReadyRead();
64 void handshakeTimeout();
65};
66
67QT_END_NAMESPACE
68
69#endif // QQMLDEBUGCONNECTION_P_H
70

source code of qtdeclarative/src/qmldebug/qqmldebugconnection_p.h