Process JSON-RPC request (with optional "timestamp" field for scheduling) Returns JSON-RPC response: {"result": ...} or {"error": {...}}.
154 {
155#if FL_PLATFORM_HAS_LARGE_MEMORY
156
157
158
159 u32 timestamp = 0;
160 if (request.
contains(
"timestamp") && request[
"timestamp"].is_int()) {
161 timestamp =
static_cast<u32
>(request[
"timestamp"].
as_int().
value());
162 }
163#endif
164
166
167#if FL_PLATFORM_HAS_LARGE_MEMORY
168
169 if (timestamp != 0) {
170
171 scheduleFunction(timestamp, receivedAt, request);
172 FL_DBG(
"RPC: Scheduled function - result will be pushed after execution");
173
174
178 }
179 response.set(
"result", fl::json(
nullptr));
182 }
183#endif
184
185
186
187#if FL_PLATFORM_HAS_LARGE_MEMORY
188
189
190
191
192
194 fl::string methodName = request[
"method"].
as_string().value_or(
"");
196 mAsyncRequests[methodName] = {
requestId, receivedAt};
198 }
199#endif
200
201
203
204#if FL_PLATFORM_HAS_LARGE_MEMORY
205
206
207
208 bool ackAlready = (
response.contains(
"ackOnly") && response[
"ackOnly"].as_bool().value_or(
false))
209 || (
response.contains(
"__async") && response[
"__async"].as_bool().value_or(
false));
210 if (ackAlready) {
211
212
214 nullResponse.
set(
"noEnqueue",
true);
215 return nullResponse;
216 }
217
218
220 fl::string methodName = request[
"method"].
as_string().value_or(
"");
221 mAsyncRequests.erase(methodName);
222 }
223#endif
224
225#if FL_PLATFORM_HAS_LARGE_MEMORY
226
227
228
230 fl::string funcName = request[
"method"].
as_string().value_or(
"");
231 recordResult(funcName, response["result"], 0, receivedAt, receivedAt, false);
232 }
233#else
234 (void)receivedAt;
235#endif
236
238}
const char * c_str() const FL_NO_EXCEPT
fl::optional< fl::string > as_string() const FL_NO_EXCEPT
fl::optional< i64 > as_int() const FL_NO_EXCEPT
void set(const fl::string &key, const json &value) FL_NO_EXCEPT
bool contains(size_t idx) const FL_NO_EXCEPT
static json object() FL_NO_EXCEPT
constexpr int type_rank< T >::value
fl::u32 millis() FL_NO_EXCEPT
Universal millisecond timer - returns milliseconds since system startup.