mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-11 22:17:17 +03:00
See CHANGELOG - release
This commit is contained in:
@@ -12,6 +12,8 @@
|
||||
|
||||
using namespace bell;
|
||||
|
||||
std::mutex BellHTTPServer::initMutex;
|
||||
|
||||
class WebSocketHandler : public CivetWebSocketHandler {
|
||||
public:
|
||||
BellHTTPServer::WSDataHandler dataHandler;
|
||||
@@ -187,6 +189,7 @@ bool BellHTTPServer::handlePost(CivetServer* server,
|
||||
}
|
||||
|
||||
BellHTTPServer::BellHTTPServer(int serverPort) {
|
||||
std::lock_guard lock(initMutex);
|
||||
mg_init_library(0);
|
||||
BELL_LOG(info, "HttpServer", "Server listening on port %d", serverPort);
|
||||
this->serverPort = serverPort;
|
||||
@@ -197,6 +200,11 @@ BellHTTPServer::BellHTTPServer(int serverPort) {
|
||||
server = std::make_unique<CivetServer>(civetWebOptions);
|
||||
}
|
||||
|
||||
BellHTTPServer::~BellHTTPServer() {
|
||||
std::lock_guard lock(initMutex);
|
||||
mg_exit_library();
|
||||
}
|
||||
|
||||
std::unique_ptr<BellHTTPServer::HTTPResponse> BellHTTPServer::makeJsonResponse(
|
||||
const std::string& json, int status) {
|
||||
auto response = std::make_unique<BellHTTPServer::HTTPResponse>();
|
||||
|
||||
@@ -19,6 +19,7 @@ namespace bell {
|
||||
class BellHTTPServer : public CivetHandler {
|
||||
public:
|
||||
BellHTTPServer(int serverPort);
|
||||
~BellHTTPServer();
|
||||
|
||||
enum class WSState { CONNECTED, READY, CLOSED };
|
||||
|
||||
@@ -100,6 +101,8 @@ class BellHTTPServer : public CivetHandler {
|
||||
std::mutex responseMutex;
|
||||
HTTPHandler notFoundHandler;
|
||||
|
||||
static std::mutex initMutex;
|
||||
|
||||
bool handleGet(CivetServer* server, struct mg_connection* conn);
|
||||
bool handlePost(CivetServer* server, struct mg_connection* conn);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user