Refactors event socket

This commit is contained in:
Rune Harlyk
2024-11-07 16:58:19 +01:00
committed by Rune Harlyk
parent fd652bd967
commit 89611b5e3e
20 changed files with 98 additions and 127 deletions
+4 -5
View File
@@ -15,7 +15,7 @@
#include <ArduinoJson.h>
#include <filesystem.h>
#include <EventSocket.h>
#include <event_socket.h>
#include <TaskManager.h>
#include <WiFi.h>
#include <Timing.h>
@@ -26,7 +26,7 @@
class AnalyticsService {
public:
AnalyticsService(EventSocket *socket, TaskManager *taskManager) : _socket(socket), _taskManager(taskManager) {};
AnalyticsService(TaskManager *taskManager) : _taskManager(taskManager) {};
void begin() {};
@@ -35,11 +35,10 @@ class AnalyticsService {
char message[MAX_ESP_ANALYTICS_SIZE];
private:
EventSocket *_socket;
TaskManager *_taskManager;
void updateAnalytics() {
if (!_socket->hasSubscribers(EVENT_ANALYTICS)) return;
if (!socket.hasSubscribers(EVENT_ANALYTICS)) return;
doc.clear();
doc["uptime"] = millis() / 1000;
doc["free_heap"] = ESP.getFreeHeap();
@@ -62,6 +61,6 @@ class AnalyticsService {
}
serializeJson(doc, message);
_socket->emit(EVENT_ANALYTICS, message);
socket.emit(EVENT_ANALYTICS, message);
}
};