-
Notifications
You must be signed in to change notification settings - Fork 1
/
WebServerController.h
42 lines (34 loc) · 1.22 KB
/
WebServerController.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#if !defined(WEB_SERVER_CONTROLLER_H)
#define WEB_SERVER_CONTROLLER_H
#include <ESP8266WebServer.h>
#include <ArduinoWebsockets.h>
#include <Arduino_JSON.h>
#include <vector>
#include "ComponentController.h"
class CapacitorController;
class PowerMonitor;
class AutoTuneController;
class WebServerController : public ComponentController
{
public:
WebServerController(CapacitorController* pCapacitorController, PowerMonitor* pPowerMonitor, AutoTuneController* pAutoTuneController);
virtual ~WebServerController();
virtual void setup();
virtual void process();
void closeAll();
private:
ESP8266WebServer server_;
CapacitorController* pCapacitorController_;
PowerMonitor* pPowerMonitor_;
AutoTuneController* pAutoTuneController_;
websockets::WebsocketsServer socketServer_;
std::vector<websockets::WebsocketsClient> clientList_;
std::vector<unsigned int> lastHeardTime_;
std::vector<bool> pongWaiting_;
JSONVar currentStatus_;
void handleNotFound_();
JSONVar generateStatusOutput_();
void sendStatusToClient_(websockets::WebsocketsClient& client, JSONVar newStatus);
void handleClientRequest_(websockets::WebsocketsClient& client, websockets::WebsocketsMessage msg);
};
#endif // WEB_SERVER_CONTROLLER_H