|
FastLED 3.9.15
|
Example demonstrating bidirectional HTTP streaming RPC (server + client in same process)
This example shows how to:
This is useful for:
Definition in file RpcBidirectional.ino.
#include <FastLED.h>#include "fl/remote/remote.h"#include "fl/remote/rpc/response_send.h"#include "fl/net/http/stream_server.h"#include "fl/net/http/stream_client.h"#include "fl/net/http/stream_server.cpp.hpp"#include "fl/net/http/stream_client.cpp.hpp"#include "fl/net/http/stream_transport.cpp.hpp"#include "fl/stl/asio/http/connection.cpp.hpp"#include "fl/net/http/chunked_encoding.cpp.hpp"#include "fl/stl/asio/http/http_parser.cpp.hpp"#include "fl/stl/asio/http/native_server.cpp.hpp"#include "fl/stl/asio/http/native_client.cpp.hpp"#include <thread>#include <atomic>#include "fl/stl/chrono.h"#include "fl/stl/thread.h"
Include dependency graph for RpcBidirectional.ino:Go to the source code of this file.
Classes | |
| struct | ServerCleanup |
Macros | |
| #define | DATA_PIN 3 |
| #define | NUM_LEDS 10 |
| #define | SERVER_PORT 0 |
Enumerations | |
| enum | TestMode { TEST_SYNC , TEST_ASYNC , TEST_ASYNC_STREAM } |
Functions | |
| void | handleClientResponse (const fl::json &response) |
| void | loop () |
| void | sendAsyncRequest () |
| void | sendAsyncStreamRequest () |
| void | sendSyncRequest () |
| std::atomic< bool > | serverRunning (false) |
| void | serverThreadFunc () |
| void | setup () |
Variables | |
| fl::unique_ptr< fl::Remote > | clientRemote |
| fl::unique_ptr< fl::net::http::HttpStreamClient > | clientTransport |
| TestMode | currentMode = TEST_SYNC |
| uint32_t | lastRequestTime = 0 |
| CRGB | leds [NUM_LEDS] |
| const uint32_t | REQUEST_INTERVAL = 3000 |
| int | requestId = 1 |
| static ServerCleanup | serverCleanup |
| fl::unique_ptr< fl::Remote > | serverRemote |
| std::thread | serverThread |
| fl::unique_ptr< fl::net::http::HttpStreamServer > | serverTransport |
| bool | waitingForResponse = false |