FastLED 3.9.15
Loading...
Searching...
No Matches

◆ sendAsyncResponse()

void fl::Remote::sendAsyncResponse ( const char * method,
const fl::json & result )

Send async response for a previously-called async method The request ID is automatically retrieved from internal storage.

Definition at line 34 of file remote.cpp.hpp.

34 {
35 fl::string methodName(method);
36 auto it = mAsyncRequests.find(methodName);
37 if (it == mAsyncRequests.end()) {
38 FL_WARN("No pending async request for method: " << method);
39 return;
40 }
41
42 int requestId = it->second.requestId;
43 mAsyncRequests.erase(it);
44
45 // Build JSON-RPC response
46 fl::json response = fl::json::object();
47 response.set("jsonrpc", "2.0");
48 response.set("id", requestId);
49 response.set("result", result);
50
51 // Send via response sink
52 if (mResponseSink) {
53 mResponseSink(response);
54 FL_DBG("Sent async response for " << method << " (id=" << requestId << ")");
55 }
56}
int requestId
fl::unordered_map< fl::string, AsyncRequest > mAsyncRequests
Definition remote.h:201
ResponseSink mResponseSink
Definition server.h:89
static json object() FL_NOEXCEPT
Definition json.h:692
#define FL_WARN(X)
Definition log.h:276
#define FL_DBG
Definition log.h:388
expected< T, E > result
Alias for expected (Rust-style naming)
Definition result.h:31

References FL_DBG, FL_WARN, mAsyncRequests, fl::Server::mResponseSink, fl::json::object(), and requestId.

+ Here is the call graph for this function: