| 190 | // ============================================================================= |
| 191 | |
| 192 | fl::optional<json> Rpc::handle_maybe(const json& request) { |
| 193 | // If no id, this is a notification - process but don't return response |
| 194 | if (!request.contains("id")) { |
| 195 | // Still need to execute the method |
| 196 | if (request.contains("method")) { |
| 197 | auto methodOpt = request["method"].as_string(); |
| 198 | if (methodOpt.has_value()) { |
| 199 | fl::string methodName = methodOpt.value(); |
| 200 | auto it = mRegistry.find(methodName); |
| 201 | if (it != mRegistry.end()) { |
| 202 | json params = request.contains("params") ? request["params"] : json::parse("[]"); |
| 203 | if (params.is_array()) { |
| 204 | it->second.mInvoker->invoke(params); |
| 205 | } |
| 206 | } |
| 207 | } |
| 208 | } |
| 209 | return fl::nullopt; |
| 210 | } |
| 211 | |
| 212 | return handle(request); |
| 213 | } |
| 214 | |
| 215 | // ============================================================================= |
| 216 | // Rpc::tags() - Returns list of unique tags |