32 lines
762 B
C++
32 lines
762 B
C++
#ifndef BEERSERVICE_H
|
|
#define BEERSERVICE_H
|
|
|
|
#include <QObject>
|
|
#include <QtWebSockets/QWebSocket>
|
|
|
|
class BeerService : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit BeerService(QObject *parent = nullptr);
|
|
~BeerService();
|
|
|
|
Q_INVOKABLE void connectSrv(const QString &userId = QString());
|
|
Q_INVOKABLE void sendCommand(const QString &entity, const QString &action, const QVariantMap &data = QVariantMap());
|
|
Q_INVOKABLE void connectListener(QObject *listener);
|
|
|
|
private:
|
|
QString stashFileName() const;
|
|
void saveStash() const;
|
|
void restoreStash();
|
|
void sendCommand(const QVariantMap &command);
|
|
|
|
QMultiMap<QString, QObject *> m_listeners;
|
|
|
|
QWebSocket m_socket;
|
|
QVariantList m_commandStash;
|
|
};
|
|
|
|
#endif // BEERSERVICE_H
|