-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWebHandler.h
45 lines (39 loc) · 1.45 KB
/
WebHandler.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
#ifndef INCLUDE_WEBHANDLER_H_
#define INCLUDE_WEBHANDLER_H_
#include <thread>
#include <unordered_set>
#include <crow.h>
#include <crow/middlewares/cors.h>
#include <string>
#include "BluetoothHandler.h"
#include "ContentHandler.h"
#include "MusicHandler.h"
#include "TagHandler.h"
#include "State.h"
class WebHandler {
private:
std::future<void> webserver;
crow::App<crow::CORSHandler> app;
BluetoothHandler* bluetoothHandler;
ContentHandler* contentHandler;
MusicHandler* musicHandler;
TagHandler* tagHandler;
std::mutex mutexConnectedClients;
std::unordered_set<crow::websocket::connection*> connectedClients;
MusicBox::State* applicationState;
crow::response upload(const crow::request& request);
void handleWebsocketData (crow::websocket::connection& , const std::string& data, bool is_binary);
std::string sanitizeFileName(const std::string& fileName) const;
public:
WebHandler() = default;
~WebHandler();
void startWebinterface();
void stopWebinterface();
void setBluetoothHandler(BluetoothHandler* blHandler);
void setContentHandler(ContentHandler* cHandler);
void setMusicHandler(MusicHandler* mHandler);
void setTagHandler(TagHandler* tHandler);
void sendMessage(const std::string msg);
void setStateInstance(MusicBox::State* state);
};
#endif