mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 07:49:52 +03:00
rename msgpack
This commit is contained in:
@@ -47,12 +47,12 @@ class AsyncJsonResponse : public AsyncAbstractResponse {
|
|||||||
JsonDocument _jsonBuffer;
|
JsonDocument _jsonBuffer;
|
||||||
JsonVariant _root;
|
JsonVariant _root;
|
||||||
bool _isValid;
|
bool _isValid;
|
||||||
bool _msgPack;
|
bool _isMsgPack;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AsyncJsonResponse(bool isArray = false, bool msgPack = false)
|
AsyncJsonResponse(bool isArray = false, bool isMsgPack = false)
|
||||||
: _isValid{false}
|
: _isValid{false}
|
||||||
, _msgPack{msgPack} {
|
, _isMsgPack{isMsgPack} {
|
||||||
_code = 200;
|
_code = 200;
|
||||||
_contentType = JSON_MIMETYPE;
|
_contentType = JSON_MIMETYPE;
|
||||||
if (isArray)
|
if (isArray)
|
||||||
@@ -70,7 +70,7 @@ class AsyncJsonResponse : public AsyncAbstractResponse {
|
|||||||
return _isValid;
|
return _isValid;
|
||||||
}
|
}
|
||||||
size_t setLength() {
|
size_t setLength() {
|
||||||
_contentLength = _msgPack ? measureMsgPack(_root) : measureJson(_root);
|
_contentLength = _isMsgPack ? measureMsgPack(_root) : measureJson(_root);
|
||||||
|
|
||||||
if (_contentLength) {
|
if (_contentLength) {
|
||||||
_isValid = true;
|
_isValid = true;
|
||||||
@@ -84,7 +84,7 @@ class AsyncJsonResponse : public AsyncAbstractResponse {
|
|||||||
|
|
||||||
size_t _fillBuffer(uint8_t * data, size_t len) {
|
size_t _fillBuffer(uint8_t * data, size_t len) {
|
||||||
ChunkPrint dest(data, _sentLength, len);
|
ChunkPrint dest(data, _sentLength, len);
|
||||||
_msgPack ? serializeMsgPack(_root, dest) : serializeJson(_root, dest);
|
_isMsgPack ? serializeMsgPack(_root, dest) : serializeJson(_root, dest);
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -86,61 +86,18 @@ class PrettyAsyncJsonResponse {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class MsgpackAsyncJsonResponse {
|
|
||||||
protected:
|
|
||||||
JsonDocument _jsonBuffer;
|
|
||||||
JsonVariant _root;
|
|
||||||
bool _isValid;
|
|
||||||
|
|
||||||
public:
|
|
||||||
MsgpackAsyncJsonResponse(bool isArray = false)
|
|
||||||
: _isValid{false} {
|
|
||||||
if (isArray)
|
|
||||||
_root = _jsonBuffer.to<JsonArray>();
|
|
||||||
else
|
|
||||||
_root = _jsonBuffer.add<JsonObject>();
|
|
||||||
}
|
|
||||||
|
|
||||||
~MsgpackAsyncJsonResponse() {
|
|
||||||
}
|
|
||||||
|
|
||||||
JsonVariant getRoot() {
|
|
||||||
return _root;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool _sourceValid() const {
|
|
||||||
return _isValid;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t setLength() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setContentType(const char * s) {
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t getSize() {
|
|
||||||
return _jsonBuffer.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t _fillBuffer(uint8_t * data, size_t len) {
|
|
||||||
return len;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setCode(uint16_t) {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class AsyncJsonResponse {
|
class AsyncJsonResponse {
|
||||||
protected:
|
protected:
|
||||||
JsonDocument _jsonBuffer;
|
JsonDocument _jsonBuffer;
|
||||||
|
|
||||||
JsonVariant _root;
|
JsonVariant _root;
|
||||||
bool _isValid;
|
bool _isValid;
|
||||||
|
bool _isMsgPack;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AsyncJsonResponse(bool isArray = false)
|
AsyncJsonResponse(bool isArray = false, bool isMsgPack = false)
|
||||||
: _isValid{false} {
|
: _isValid{false}
|
||||||
|
, _isMsgPack{isMsgPack} {
|
||||||
if (isArray)
|
if (isArray)
|
||||||
_root = _jsonBuffer.to<JsonArray>();
|
_root = _jsonBuffer.to<JsonArray>();
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user