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

◆ sendStreamFinal()

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

Send final stream response for a streaming async method (ASYNC_STREAM mode) The request ID is automatically retrieved from internal storage and method is removed.

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

85 {
86 fl::string methodName(method);
87 auto it = mAsyncRequests.find(methodName);
88 if (it == mAsyncRequests.end()) {
89 FL_WARN("No pending async request for method: " << method);
90 return;
91 }
92
93 int requestId = it->second.requestId;
94 mAsyncRequests.erase(it); // Stream complete - remove request
95
96 // Build JSON-RPC response with "stop" marker
97 fl::json response = fl::json::object();
98 response.set("jsonrpc", "2.0");
99 response.set("id", requestId);
100
101 fl::json resultObj = fl::json::object();
102 resultObj.set("value", result);
103 resultObj.set("stop", true);
104 response.set("result", resultObj);
105
106 // Send via response sink
107 if (mResponseSink) {
108 mResponseSink(response);
109 FL_DBG("Sent stream final for " << method << " (id=" << requestId << ")");
110 }
111}
int requestId
fl::unordered_map< fl::string, AsyncRequest > mAsyncRequests
Definition remote.h:201
ResponseSink mResponseSink
Definition server.h:89
void set(const fl::string &key, const json &value) FL_NOEXCEPT
Definition json.h:701
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(), requestId, and fl::json::set().

+ Here is the call graph for this function: