Process JSON-RPC request (with optional "timestamp" field for scheduling) Returns JSON-RPC response: {"result": ...} or {"error": {...}}.
134 {
135
136 u32 timestamp = 0;
137 if (request.
contains(
"timestamp") && request[
"timestamp"].is_int()) {
138 timestamp =
static_cast<u32
>(request[
"timestamp"].
as_int().
value());
139 }
140
142
143
144 if (timestamp == 0) {
145
146
148 fl::string methodName = request[
"method"].
as_string().value_or(
"");
152 }
153
154
156
157
158 if (
response.contains(
"__async") && response[
"__async"].as_bool().value_or(
false)) {
159
160
162 nullResponse.
set(
"__skip",
true);
163 return nullResponse;
164 }
165
166
168 fl::string methodName = request[
"method"].
as_string().value_or(
"");
170 }
171
172
174 fl::string funcName = request[
"method"].
as_string().value_or(
"");
175 recordResult(funcName, response[
"result"], 0, receivedAt, receivedAt,
false);
176 }
177
179 } else {
180
182 FL_DBG(
"RPC: Scheduled function - result will be pushed after execution");
183
184
188 }
189 response.set(
"result", fl::json(
nullptr));
192 }
193}
void recordResult(const fl::string &funcName, const fl::json &result, u32 scheduledAt, u32 receivedAt, u32 executedAt, bool wasScheduled)
void scheduleFunction(u32 timestamp, u32 receivedAt, const fl::json &jsonRpcRequest)
fl::unordered_map< fl::string, AsyncRequest > mAsyncRequests
const char * c_str() const FL_NOEXCEPT
fl::optional< i64 > as_int() const FL_NOEXCEPT
bool contains(size_t idx) const FL_NOEXCEPT
fl::optional< fl::string > as_string() const FL_NOEXCEPT
void set(const fl::string &key, const json &value) FL_NOEXCEPT
static json object() FL_NOEXCEPT
constexpr int type_rank< T >::value
fl::u32 millis()
Universal millisecond timer - returns milliseconds since system startup.