MCPcopy Create free account
hub / github.com/FastLED/FastLED / resolveRpcStream

Method resolveRpcStream

src/fl/net/http/stream_transport.cpp.hpp:158–207  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

156}
157
158bool HttpStreamTransport::resolveRpcStream(const fl::json& msg, const fl::string& idKey) {
159 auto it = mPendingStreams.find(idKey);
160 if (it == mPendingStreams.end()) {
161 return false;
162 }
163 PendingStream* pending = &it->second;
164
165 // Check for error
166 if (msg.contains("error")) {
167 fl::task::Error err(msg["error"]["message"].as_string().value());
168 pending->promise.complete_with_error(err);
169 mPendingStreams.erase(idKey);
170 return true;
171 }
172
173 // Check for ACK
174 if (msg.contains("result") && msg["result"].contains("acknowledged")) {
175 if (msg["result"]["acknowledged"].as_bool() == true) {
176 pending->ackReceived = true;
177 return true;
178 }
179 }
180
181 // Check for stream update
182 if (msg.contains("result") && msg["result"].contains("update")) {
183 if (pending->updateCallback && *pending->updateCallback) {
184 (*pending->updateCallback)(msg["result"]["update"]);
185 }
186 return true;
187 }
188
189 // Check for stream final (stop marker)
190 if (msg.contains("result") && msg["result"].contains("stop")) {
191 if (msg["result"]["stop"].as_bool() == true) {
192 // Resolve with the value field if present, otherwise the full result
193 if (msg["result"].contains("value")) {
194 pending->promise.complete_with_value(msg["result"]["value"]);
195 } else {
196 pending->promise.complete_with_value(msg["result"]);
197 }
198 mPendingStreams.erase(idKey);
199 return true;
200 }
201 }
202
203 // Unrecognized message shape - treat as final
204 pending->promise.complete_with_value(msg);
205 mPendingStreams.erase(idKey);
206 return true;
207}
208
209fl::task::Promise<fl::json> HttpStreamTransport::rpc(const fl::string& method, const fl::json& params) {
210 int id = mNextCallId++;

Callers

nothing calls this directly

Calls 9

complete_with_errorMethod · 0.80
complete_with_valueMethod · 0.80
findMethod · 0.45
endMethod · 0.45
containsMethod · 0.45
valueMethod · 0.45
as_stringMethod · 0.45
eraseMethod · 0.45
as_boolMethod · 0.45

Tested by

no test coverage detected