FastLED 3.9.15
Loading...
Searching...
No Matches
RpcBidirectional.ino File Reference

Detailed Description

Example demonstrating bidirectional HTTP streaming RPC (server + client in same process)

This example shows how to:

  • Run both HTTP RPC server and client in the same application
  • Server binds methods (SYNC, ASYNC, ASYNC_STREAM)
  • Client connects to server via loopback (localhost)
  • Demonstrate all three RPC modes over HTTP streaming
  • Handle responses and visualize on LEDs

This is useful for:

  • Testing RPC functionality without multiple processes
  • Building applications with internal RPC communication
  • Demonstrating full HTTP streaming RPC capabilities
See also
fl/remote/remote.h for full API documentation
fl/stl/asio/http/PROTOCOL.md for protocol specification

Definition in file RpcBidirectional.ino.

+ 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::RemoteclientRemote
 
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::RemoteserverRemote
 
std::thread serverThread
 
fl::unique_ptr< fl::net::http::HttpStreamServer > serverTransport
 
bool waitingForResponse = false