🎨 Renames webserver and websocket
This commit is contained in:
+4
-4
@@ -21,10 +21,10 @@ struct HttpRoute {
|
||||
bool isWebsocket;
|
||||
};
|
||||
|
||||
class NativeServer {
|
||||
class WebServer {
|
||||
public:
|
||||
NativeServer();
|
||||
~NativeServer();
|
||||
WebServer();
|
||||
~WebServer();
|
||||
|
||||
void config(size_t maxUriHandlers, size_t stackSize);
|
||||
esp_err_t listen(uint16_t port);
|
||||
@@ -72,4 +72,4 @@ class NativeServer {
|
||||
esp_err_t registerRoute(const HttpRoute& route);
|
||||
};
|
||||
|
||||
extern NativeServer nativeServer;
|
||||
extern WebServer server;
|
||||
+4
-4
@@ -1,17 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <communication/native_server.h>
|
||||
#include <communication/webserver.h>
|
||||
#include <communication/comm_base.hpp>
|
||||
|
||||
class NativeWebsocket : public CommAdapterBase {
|
||||
class Websocket : public CommAdapterBase {
|
||||
public:
|
||||
NativeWebsocket(NativeServer& server, const char* route = "/api/ws");
|
||||
Websocket(WebServer& server, const char* route = "/api/ws");
|
||||
|
||||
void begin() override;
|
||||
|
||||
private:
|
||||
NativeServer& server_;
|
||||
WebServer& server_;
|
||||
const char* route_;
|
||||
|
||||
void onWsOpen(httpd_req_t* req);
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <esp_http_server.h>
|
||||
#include <ArduinoJson.h>
|
||||
#include <template/stateful_service.h>
|
||||
#include <communication/native_server.h>
|
||||
#include <communication/webserver.h>
|
||||
|
||||
#include <functional>
|
||||
|
||||
@@ -27,7 +27,7 @@ class StatefulHttpEndpoint {
|
||||
StateUpdateResult outcome = _statefulService->updateWithoutPropagation(jsonObject, _stateUpdater);
|
||||
|
||||
if (outcome == StateUpdateResult::ERROR) {
|
||||
return NativeServer::sendError(request, 400, "Invalid state");
|
||||
return WebServer::sendError(request, 400, "Invalid state");
|
||||
} else if ((outcome == StateUpdateResult::CHANGED)) {
|
||||
_statefulService->callUpdateHandlers(HTTP_ENDPOINT_ORIGIN_ID);
|
||||
}
|
||||
@@ -35,13 +35,13 @@ class StatefulHttpEndpoint {
|
||||
JsonDocument doc;
|
||||
JsonVariant root = doc.to<JsonVariant>();
|
||||
_statefulService->read(root, _stateReader);
|
||||
return NativeServer::sendJson(request, 200, doc);
|
||||
return WebServer::sendJson(request, 200, doc);
|
||||
}
|
||||
|
||||
esp_err_t getState(httpd_req_t *request) {
|
||||
JsonDocument doc;
|
||||
JsonVariant root = doc.to<JsonVariant>();
|
||||
_statefulService->read(root, _stateReader);
|
||||
return NativeServer::sendJson(request, 200, doc);
|
||||
return WebServer::sendJson(request, 200, doc);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
#include <communication/native_server.h>
|
||||
#include <communication/webserver.h>
|
||||
#include "WWWData.h"
|
||||
|
||||
void mountStaticAssets(NativeServer& s);
|
||||
void mountStaticAssets(WebServer& s);
|
||||
|
||||
Reference in New Issue
Block a user