138template<
typename Sig>
141template<
typename R,
typename... Args>
185 template<
typename Callable>
239 template<typename Callable>
243 registerMethod<Sig>(config.name.c_str(), wrapped, config.params, config.description, config.tags, config.mode);
247 template<
typename Callable>
289 it->second.mTypedCallable.get());
376#if FL_PLATFORM_HAS_LARGE_MEMORY
382#if FL_PLATFORM_HAS_LARGE_MEMORY
393#if FL_PLATFORM_HAS_LARGE_MEMORY
394 if (!paramNames.empty()) {
408#if FL_PLATFORM_HAS_LARGE_MEMORY
fl::UIDescription description("Demo of the Animatrix effects. @author of fx is StefanPetrick")
Helper class for sending responses in async/streaming RPC methods.
void bindAsync(const char *name, fl::function< void(ResponseSend &, const json &)> fn, fl::RpcMode mode=fl::RpcMode::ASYNC) FL_NO_EXCEPT
Bind async method with ResponseSend& parameter (for ASYNC/ASYNC_STREAM modes) Signature: void(Respons...
fl::unordered_map< fl::string, detail::RpcEntry > mRegistry
bool has(const char *name) const FL_NO_EXCEPT
Check if a method is registered (regardless of signature).
bool registerMethod(const char *name, RpcFn< Sig > fn, const fl::vector< fl::string > ¶mNames, const fl::string &description, const fl::vector< fl::string > &tags, fl::RpcMode mode=fl::RpcMode::SYNC) FL_NO_EXCEPT
void bind(const Config< Callable > &config) FL_NO_EXCEPT
Bind a method with configuration (name, function, optional metadata).
void bindStreaming(const char *name, fl::StreamingRpcHandler fn) FL_NO_EXCEPT
Bind a method that streams its JSON-RPC result directly to the transport.
void clear() FL_NO_EXCEPT
Clear all registered methods.
fl::optional< json > handle_maybe(const json &request) FL_NO_EXCEPT
For notifications (no id), returns nullopt.
void setResponseStreamSink(fl::ResponseStreamSink sink) FL_NO_EXCEPT
Set response stream sink for methods registered with bindStreaming().
bool unbind(const char *name) FL_NO_EXCEPT
Unbind (unregister) a previously registered method.
Rpc() FL_NO_EXCEPT=default
fl::function< void(const fl::json &)> mResponseSink
json schema() const FL_NO_EXCEPT
Returns flat schema document.
json handle(const json &request) FL_NO_EXCEPT
Process a JSON-RPC request.
void setResponseSink(fl::function< void(const fl::json &)> sink) FL_NO_EXCEPT
Set response sink for sending ACK responses (used by async functions)
fl::vector< fl::string > tags() const FL_NO_EXCEPT
Returns list of unique tags used across all methods.
BindResult< Sig > get(const char *name) const FL_NO_EXCEPT
Get a registered method by name.
fl::size count() const FL_NO_EXCEPT
Returns number of registered methods.
json methods() const FL_NO_EXCEPT
Returns flat method array: [["name", "returnType", [["param1", "type1"], ...]], .....
void bind(const char *name, Callable fn, fl::RpcMode mode=fl::RpcMode::SYNC) FL_NO_EXCEPT
Convenience overload: bind method by name, function, and optional mode.
expected type for operations that can fail (C++23-style)
Generic expected<T, E> type for error handling without exceptions.
FastLED's Elegant JSON Library: fl::json
constexpr remove_reference< T >::type && move(T &&t) FL_NO_EXCEPT
shared_ptr< T > make_shared(Args &&... args) FL_NO_EXCEPT
constexpr T && forward(typename remove_reference< T >::type &t) FL_NO_EXCEPT
fl::shared_ptr< RuntimeRpcBinding > makeRuntimeRpcBinding(fl::function< R(Args...)> fn) FL_NO_EXCEPT
fl::shared_ptr< ErasedInvoker > mInvoker
fl::shared_ptr< ErasedSchemaGenerator > mSchemaGenerator
fl::shared_ptr< CallableHolderBase > mTypedCallable
fl::vector< fl::string > mTags
u8 u8 fract8 blur_amount FL_NO_EXCEPT
fl::function< Sig > RpcFn
fl::function< void(fl::JsonStreamWriter &, const fl::json &, const fl::json &)> StreamingRpcHandler
fl::function< void(fl::JsonStreamCallback)> ResponseStreamSink
enable_if< is_fixed_point< T >::value, T >::type exp(T x) FL_NO_EXCEPT
Base definition for an LED controller.
fl::vector< ParamInfo > params
fl::vector< fl::string > tags
Method parameter information.
Wraps the result of binding to a method by name.
RpcFn< R(Args...)> & value() FL_NO_EXCEPT
RpcFn< R(Args...)> value() const FL_NO_EXCEPT
Get the callable (requires has_value())
bool ok() const FL_NO_EXCEPT
BindResult(fl::expected< RpcFn< R(Args...)>, BindError > exp) FL_NO_EXCEPT
Construct from expected.
const fl::expected< RpcFn< R(Args...)>, BindError > & get() const FL_NO_EXCEPT
Access the underlying expected.
R operator()(Args... args) const FL_NO_EXCEPT
Call the bound function directly (undefined behavior if binding failed) Always check ok() or has_valu...
BindResult(RpcFn< R(Args...)> fn) FL_NO_EXCEPT
Construct from RpcFn (success case)
fl::expected< RpcFn< R(Args...)>, BindError > inner
BindError error() const FL_NO_EXCEPT
Get the error (undefined if has_value())
bool has_value() const FL_NO_EXCEPT
Check if binding succeeded.
fl::vector< fl::string > params
Parameter names (optional)
Config(fl::string n, Callable f, fl::RpcMode m=fl::RpcMode::SYNC) FL_NO_EXCEPT
Constructor requiring name and function (metadata is optional)
fl::string name
Method name (REQUIRED)
fl::vector< fl::string > tags
Tags for grouping (optional)
Callable fn
Function to register (REQUIRED)
Config(fl::string n, Callable f, fl::vector< fl::string > p, fl::RpcMode m=fl::RpcMode::SYNC) FL_NO_EXCEPT
Constructor with params.
fl::RpcMode mode
Execution mode (SYNC or ASYNC, default SYNC)
Config(fl::string n, Callable f, fl::vector< fl::string > p, fl::string desc, fl::vector< fl::string > t={}, fl::RpcMode m=fl::RpcMode::SYNC) FL_NO_EXCEPT
Constructor with all fields.
fl::string description
Method description (optional)
Configuration for method registration with optional metadata.
static const void * id() FL_NO_EXCEPT