Skip to content
This repository was archived by the owner on Jan 21, 2025. It is now read-only.

Commit 4873863

Browse files
committed
Website update
1 parent b66ffe8 commit 4873863

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

docs/index.md

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ This fork is based on https://github.com/yubox-node-org/ESPAsyncWebServer and in
1515
- Deployed in PlatformIO registry and Arduino IDE library manager
1616
- CI
1717
- Only supports ESP32
18+
- Resurrected `AsyncWebSocketMessageBuffer` and `makeBuffer()` in order to make the fork API-compatible with the original library from me-no-dev regarding WebSocket.
1819

1920
## Documentation
2021

@@ -23,13 +24,29 @@ Please look at the original libraries for more examples and documentation.
2324

2425
[https://github.com/yubox-node-org/ESPAsyncWebServer](https://github.com/yubox-node-org/ESPAsyncWebServer)
2526

26-
## Pitfalls
27+
## `AsyncWebSocketMessageBuffer` and `makeBuffer()`
2728

28-
The fork from yubox introduces some breaking API changes compared to the original library, especially regarding the use of `std::shared_ptr<std::vector<uint8_t>>` for WebSocket.
29-
Thanks to this fork, you can handle them by using `ASYNCWEBSERVER_FORK_mathieucarbou`.
29+
The fork from `yubox-node-org` introduces some breaking API changes compared to the original library, especially regarding the use of `std::shared_ptr<std::vector<uint8_t>>` for WebSocket.
3030

31-
Here is an example for serializing a Json document in a websocket message buffer directly.
32-
This code is compatible with both forks.
31+
This fork is compatible with the original library from `me-no-dev` regarding WebSocket, and wraps the optimizations done by `yubox-node-org` in the `AsyncWebSocketMessageBuffer` class.
32+
So you have the choice of which API to use.
33+
I strongly suggest to use the optimized API from `yubox-node-org` as it is much more efficient.
34+
35+
Here is an example for serializing a Json document in a websocket message buffer. This code is compatible with any forks, but not optimized:
36+
37+
```cpp
38+
void send(JsonDocument& doc) {
39+
const size_t len = measureJson(doc);
40+
41+
// original API from me-no-dev
42+
AsyncWebSocketMessageBuffer* buffer = _ws->makeBuffer(len);
43+
assert(buffer); // up to you to keep or remove this
44+
serializeJson(doc, buffer->get(), len);
45+
_ws->textAll(buffer);
46+
}
47+
```
48+
49+
Here is an example for serializing a Json document in a more optimized way, and compatible with both forks:
3350
3451
```cpp
3552
void send(JsonDocument& doc) {

0 commit comments

Comments
 (0)