mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2026-10-31 22:02:17 +01:00
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>
27 lines
829 B
C++
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
|