| 30 | // ============================================================================= |
| 31 | |
| 32 | void Rpc::bindAsync(const char* name, |
| 33 | fl::function<void(ResponseSend&, const json&)> fn, |
| 34 | fl::RpcMode mode) { |
| 35 | fl::string key(name); |
| 36 | |
| 37 | detail::RpcEntry entry; |
| 38 | entry.mTypeTag = detail::TypeTag<void(const json&)>::id(); |
| 39 | entry.mMode = mode; |
| 40 | entry.mIsResponseAware = true; |
| 41 | entry.mResponseAwareFn = fl::move(fn); |
| 42 | |
| 43 | #if FL_PLATFORM_HAS_LARGE_MEMORY |
| 44 | // Create schema generator for void(json) signature (params not decomposed). |
| 45 | // Gated on Low-memory per FastLED #3081 / #3079 (rpc.discover unreachable). |
| 46 | entry.mSchemaGenerator = fl::make_shared<detail::TypedSchemaGenerator<void(const json&)>>(); |
| 47 | #endif |
| 48 | entry.mDescription = ""; |
| 49 | entry.mTags = {}; |
| 50 | |
| 51 | // Create a placeholder invoker (actual invocation handled in handle()) |
| 52 | struct PlaceholderInvoker : public detail::ErasedInvoker { |
| 53 | fl::tuple<TypeConversionResult, json> invoke(const json&) override { |
| 54 | // Should not be called - handle() will call mResponseAwareFn directly |
| 55 | return fl::make_tuple(TypeConversionResult::success(), json(nullptr)); |
| 56 | } |
| 57 | }; |
| 58 | entry.mInvoker = fl::make_shared<PlaceholderInvoker>(); |
| 59 | |
| 60 | mRegistry[key] = fl::move(entry); |
| 61 | } |
| 62 | |
| 63 | // ============================================================================= |
| 64 | // Rpc::handle() - Process JSON-RPC requests |