ESPSomfy-RTS/src/WResp.h
cjkas d723c1024d refactor: move JsonFormatter into JsonFormatter.cpp
JsonFormatter and BufferedJsonFormatter move verbatim out of
WResp.cpp/WResp.h, which now include JsonFormatter.h.  They don't need
the web server, so on their own they can be unit tested on the PC; the
native env builds the new file.  AsyncJsonResp and JsonSockEvent stay
in WResp.  No behaviour change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 13:29:30 +02:00

27 lines
829 B
C++

#include <ESPAsyncWebServer.h>
#include "Somfy.h"
#ifndef wresp_h
#define wresp_h
#include "JsonFormatter.h"
class AsyncJsonResp : public JsonFormatter {
protected:
void _safecat(const char *val, bool escape = false) override;
AsyncWebServerRequest *_request = nullptr;
AsyncResponseStream *_stream = nullptr;
public:
void beginResponse(AsyncWebServerRequest *request, char *buff, size_t buffSize);
void endResponse();
void flush();
};
class JsonSockEvent : public JsonFormatter {
protected:
bool _closed = false;
void _safecat(const char *val, bool escape = false) override;
public:
AsyncWebSocket *server = nullptr;
void beginEvent(AsyncWebSocket *server, const char *evt, char *buff, size_t buffSize);
void endEvent(uint32_t clientId = 0);
void closeEvent();
};
#endif