mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2026-02-04 15:29:48 +00:00
fetch snapshot data on subsrciption
This commit is contained in:
@@ -63,7 +63,7 @@ void AWDataEngineAggregator::connectSources()
|
||||
auto keys = m_sensors.keys();
|
||||
auto newKeys = QSet(keys.cbegin(), keys.cend()) - m_subscribed;
|
||||
|
||||
m_interface->subscribe(newKeys.values()).waitForFinished();
|
||||
subscribeSources(newKeys.values());
|
||||
m_subscribed.unite(newKeys);
|
||||
}
|
||||
|
||||
@@ -106,6 +106,19 @@ void AWDataEngineAggregator::registerClient(QObject *_client)
|
||||
}
|
||||
|
||||
|
||||
void AWDataEngineAggregator::subscribeSources(const QStringList &_sources)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Subscribe on sources" << _sources;
|
||||
|
||||
// subscribe
|
||||
m_interface->subscribe(_sources).waitForFinished();
|
||||
// get data snapshot
|
||||
auto data = m_interface->sensorData(_sources);
|
||||
data.waitForFinished();
|
||||
updateData(data);
|
||||
}
|
||||
|
||||
|
||||
void AWDataEngineAggregator::unregisterClient(QObject *_client)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Unregister client" << _client;
|
||||
@@ -159,15 +172,16 @@ void AWDataEngineAggregator::sensorAdded(const QString &_sensor)
|
||||
if (!isValidSensor(info))
|
||||
return;
|
||||
|
||||
// notify about new device
|
||||
emit(deviceAdded(_sensor));
|
||||
|
||||
// process connection
|
||||
m_sensors[_sensor] = info;
|
||||
dropSource(_sensor); // force reconnect
|
||||
if (!m_subscribed.contains(_sensor)) {
|
||||
m_interface->subscribe({_sensor}).waitForFinished();
|
||||
subscribeSources({_sensor});
|
||||
m_subscribed.insert(_sensor);
|
||||
}
|
||||
|
||||
// notify about new device
|
||||
emit(deviceAdded(_sensor));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@ public:
|
||||
[[nodiscard]] static bool isValidSensor(const KSysGuard::SensorInfo &_sensor);
|
||||
void loadSources();
|
||||
void registerClient(QObject *_client);
|
||||
void subscribeSources(const QStringList &_sources);
|
||||
void unregisterClient(QObject *_client);
|
||||
|
||||
signals:
|
||||
|
||||
Reference in New Issue
Block a user