| 83 | } |
| 84 | |
| 85 | void Remote::sendStreamFinal(const char* method, const fl::json& result) { |
| 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 | } |
| 112 | |
| 113 | // Error Reporting |
| 114 | |