add mqtt control
This commit is contained in:
42
src/mqttcontroller.h
Normal file
42
src/mqttcontroller.h
Normal file
@@ -0,0 +1,42 @@
|
||||
#ifndef MQTTCONTROLLER_H
|
||||
#define MQTTCONTROLLER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
#include "appconfig.h"
|
||||
|
||||
struct mosquitto;
|
||||
struct mosquitto_message;
|
||||
|
||||
class MqttController : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MqttController(const MqttConfig &config, QObject *parent = nullptr);
|
||||
~MqttController();
|
||||
|
||||
void start();
|
||||
|
||||
signals:
|
||||
void play();
|
||||
void pause();
|
||||
void nextImage();
|
||||
void nextFolder();
|
||||
void restart();
|
||||
|
||||
private slots:
|
||||
void handleCommand(const QString &payload);
|
||||
|
||||
private:
|
||||
static void HandleConnect(struct mosquitto *mosq, void *userdata, int rc);
|
||||
static void HandleMessage(struct mosquitto *mosq, void *userdata, const struct mosquitto_message *message);
|
||||
|
||||
void subscribe();
|
||||
|
||||
MqttConfig config;
|
||||
struct mosquitto *client = nullptr;
|
||||
bool connected = false;
|
||||
};
|
||||
|
||||
#endif // MQTTCONTROLLER_H
|
||||
Reference in New Issue
Block a user