mirror of
https://github.com/qt/qtmqtt.git
synced 2026-10-25 16:16:26 +00:00
Replace the current license disclaimer in files by a SPDX-License-Identifier. License files are organized under LICENSES directory. Pick-to: 6.4 Task-number: QTBUG-67283 Change-Id: Ie4309963c8e17d4e7dad602f61a660246d5e23cb Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
40 lines
925 B
C++
40 lines
925 B
C++
// Copyright (C) 2017 The Qt Company Ltd.
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
|
|
|
#ifndef CLIENTSUBSCRIPTION_H
|
|
#define CLIENTSUBSCRIPTION_H
|
|
|
|
#include "websocketiodevice.h"
|
|
|
|
#include <QtCore/QObject>
|
|
#include <QtMqtt/QMqttClient>
|
|
#include <QtWebSockets/QWebSocket>
|
|
|
|
class ClientSubscription : public QObject
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
ClientSubscription(QObject *parent = nullptr);
|
|
|
|
void setUrl(const QUrl &url); // ie ws://broker.hivemq.com:8000/mqtt
|
|
void setTopic(const QString &topic);
|
|
void setVersion(int v);
|
|
signals:
|
|
void messageReceived(QByteArray);
|
|
void errorOccured();
|
|
|
|
public slots:
|
|
void connectAndSubscribe();
|
|
void handleMessage(const QByteArray &msgContent);
|
|
|
|
private:
|
|
QMqttClient m_client;
|
|
QMqttSubscription *m_subscription;
|
|
QUrl m_url;
|
|
QString m_topic;
|
|
WebSocketIODevice m_device;
|
|
int m_version;
|
|
};
|
|
|
|
#endif // CLIENTSUBSCRIPTION_H
|