MCPcopy Create free account
hub / github.com/FastLED/FastLED / bindAsync

Method bindAsync

src/fl/remote/rpc/rpc.cpp.hpp:32–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30// =============================================================================
31
32void 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

Callers

nothing calls this directly

Calls 1

idClass · 0.85

Tested by

no test coverage detected