Websocket auto serverinfo responder (#443)

* serverinfo cb

* remove webui cron

* missing header file

* tcp connection should trigger to
This commit is contained in:
brindosch
2017-06-17 23:29:04 +02:00
committed by GitHub
parent 91c7637a2b
commit d3707cb118
12 changed files with 166 additions and 38 deletions

View File

@@ -13,6 +13,7 @@
#include <QJsonObject>
#include <QJsonValue>
#include <QJsonArray>
#include <QTimer>
// hyperion-utils includes
#include <utils/Image.h>
@@ -170,9 +171,9 @@ public:
ComponentRegister& getComponentRegister() { return _componentRegister; };
bool configModified();
bool configModified() { return _configMod; };
bool configWriteable();
bool configWriteable() { return _configWrite; };
/// gets the methode how image is maped to leds
int getLedMappingType() { return _ledMAppingType; };
@@ -308,6 +309,9 @@ signals:
void emitImage(int priority, const Image<ColorRgb> & image, const int timeout_ms);
void closing();
/// Signal which is emitted, when state of config or bonjour or priorityMuxer changed
void hyperionStateChanged();
private slots:
///
/// Updates the priority muxer with the current time and (re)writes the led color with applied
@@ -316,9 +320,12 @@ private slots:
void update();
void currentBonjourRecordsChanged(const QList<BonjourRecord> &list);
void bonjourRecordResolved(const QHostInfo &hostInfo, int port);
void bonjourRecordResolved(const QHostInfo &hostInfo, int port);
void bonjourResolve();
/// check for configWriteable and modified changes, called by _cTimer timeout()
void checkConfigState();
private:
///
@@ -335,6 +342,7 @@ private:
LedString _ledStringClone;
std::vector<ColorOrder> _ledStringColorOrder;
/// The priority muxer
PriorityMuxer _muxer;
@@ -356,7 +364,7 @@ private:
// json configuration
const QJsonObject& _qjsonConfig;
// the name of config file
/// the name of config file
QString _configFile;
/// The timer for handling priority channel timeouts
@@ -396,4 +404,15 @@ private:
BonjourServiceResolver _bonjourResolver;
BonjourRegister _hyperionSessions;
QString _bonjourCurrentServiceToResolve;
/// Interval timer to check config write and mod
QTimer _cTimer;
/// holds the prev states of configWriteable and modified
bool _prevConfigMod = false;
bool _prevConfigWrite = true;
/// holds the current states of configWriteable and modified
bool _configMod = false;
bool _configWrite = true;
};

View File

@@ -8,6 +8,8 @@
// QT includes
#include <QMap>
#include <QObject>
#include <QTimer>
// Utils includes
#include <utils/ColorRgb.h>
@@ -18,8 +20,9 @@
/// and the muxer keeps track of all active priorities. The current priority can be queried and per
/// priority the led colors.
///
class PriorityMuxer
class PriorityMuxer : public QObject
{
Q_OBJECT
public:
///
/// The information structure for a single priority channel
@@ -118,6 +121,18 @@ public:
///
void setCurrentTime(const int64_t& now);
signals:
///
/// Signal which is called, when a effect or color with timeout is running, once per second
///
void timerunner();
private slots:
///
/// Slots which is called to adapt to 1s interval for signal timerunner()
///
void emitReq();
private:
/// The current priority (lowest value in _activeInputs)
int _currentPriority;
@@ -128,4 +143,7 @@ private:
/// The information of the lowest priority channel
InputInfo _lowestPriorityInfo;
QTimer _timer;
QTimer _blockTimer;
};

View File

@@ -6,6 +6,7 @@
// Qt includes
#include <QTcpServer>
#include <QSet>
#include <QTimer>
// Hyperion includes
#include <hyperion/Hyperion.h>
@@ -41,6 +42,10 @@ private slots:
/// Slot which is called when a client tries to create a new connection
///
void newConnection();
///
/// Slot which is called when a new forced serverinfo should be pushed
///
void pushReq();
///
/// Slot which is called when a client closes a connection
@@ -52,9 +57,15 @@ private:
/// The TCP server object
QTcpServer _server;
/// Link to Hyperion to get hyperion state emiter
Hyperion * _hyperion;
/// List with open connections
QSet<JsonClientConnection *> _openConnections;
/// the logger instance
Logger * _log;
QTimer _timer;
QTimer _blockTimer;
};