Closed tueddy closed 5 months ago
Of course! Will do it quickly in a few minutes ;-)
Do not rush ;-)
Note that I strongly avise you to use the AsyncWebSocketMessageBuffer
class instead, like in the spirit of the original fork.
std::shared_ptr<std::vector<uint8_t>>
was introduced in yubox-node-org fork as an internal way of fixing the pointers scope / references, but this should be kept internal and not be dealt with. So I added back the AsyncWebSocketMessageBuffer which wraps that without overhead.
mathieucarbou/ESP Async WebServer @ 2.10.2
is released and in PlatformIO registry ;-)
@mathieucarbou Thank's for the fast response & update! Everything is working now:
#if defined(ASYNCWEBSERVER_FORK_mathieucarbou)
// serialize JSON in a more optimized way using a shared buffer
const size_t len = measureJson(doc);
auto buffer = std::make_shared<std::vector<uint8_t>>(len);
serializeJson(doc, buffer->data(), len);
if (client == 0) {
ws.textAll(std::move(buffer));
} else {
ws.text(client, std::move(buffer));
}
#else
..
I would agree to use a higher level thing like AsyncWebSocketMessageBuffer
but your example on the webpage shows implementation like above. Do you have a suggestion to rewrite code above for AsyncWebSocketMessageBuffer
and apply the example on the documentation page?
Please note if need booth, text() & textAll() without copying data around..
Thank's & best regards Dirk
The optimized websocket delivery works fine but I miss a possibility to notify a single client with optimized delivery. Can you maybe add an overlad function for
text()
same astextAll()
?void text(uint32_t id, std::shared_ptr<std::vector> buffer);
Current:
Maybe something like this:
Thanks & best regards Dirk