-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
WrapperWebServer.h
executable file
·59 lines (46 loc) · 1.53 KB
/
WrapperWebServer.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef WrapperWebServer_h
#define WrapperWebServer_h
#include "BaseHeader.h"
#include <WebServer.h>
#include <EnhancedThread.h>
#include "BoxTimer.h"
#define SSE_MAX_CHANNELS 5
class WrapperWebServer : public EnhancedThread {
public:
struct SSESubscription {
IPAddress clientIP;
WiFiClient client;
//Ticker keepAliveTimer;
} subscription[SSE_MAX_CHANNELS];
uint8_t subscriptionCount = 0;
void
begin(),
loop();
void
sendEvent(const char* eventname, const char* content, bool escapeData = true);
//sendEventJSON(char* eventname, xyzjsondoc jsonContent)
private:
void
handleNotFound(void),
handleUnknown(void),
handleRoot(void),
handleFile(const char* path, const char* type),
handleSseSub(void),
handleAjax(void),
handleUploadFile(void),
handleUploadFlashFile(void);
void
sendJsonSuccess();
void
sseHandler(uint8_t channel),
sseKeepAlive();
bool
commandGetFile(String* path, uint32_t read_start, uint32_t read_length, bool download),
commandGetFlashFile(String* path, uint32_t read_start, uint32_t read_length);
BoxTimer _sseTimer;
WebServer* _server;
FileFs _uploadFile;
bool _uploadFileOpen = false;
bool _uploadFlashFileOpen = false;
};
#endif