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

◆ sendFinal()

void fl::ResponseSend::sendFinal ( const fl::json & result)
inline

Send final response and mark stream as complete (for ASYNC_STREAM mode)

Parameters
resultThe final result payload (any JSON value)

Creates a JSON-RPC response with "stop" marker: {"jsonrpc": "2.0", "result": {"value": <result>, "stop": true}, "id": <requestId>}

After calling sendFinal(), no more responses can be sent.

Definition at line 114 of file response_send.h.

114 {
115 if (!mResponseSink || mIsFinal) {
116 return;
117 }
118
119 mIsFinal = true;
120
121 fl::json response = fl::json::object();
122 response.set("jsonrpc", "2.0");
123
124 fl::json finalResult = fl::json::object();
125 finalResult.set("value", result);
126 finalResult.set("stop", true);
127
128 response.set("result", finalResult);
129 response.set("id", mRequestId);
130
131 mResponseSink(response);
132 }
fl::function< void(const fl::json &)> mResponseSink
void set(const fl::string &key, const json &value) FL_NOEXCEPT
Definition json.h:701
static json object() FL_NOEXCEPT
Definition json.h:692
expected< T, E > result
Alias for expected (Rust-style naming)
Definition result.h:31

References mIsFinal, mRequestId, mResponseSink, fl::json::object(), and fl::json::set().

Referenced by setup().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: