FastLED 3.9.15
Loading...
Searching...
No Matches
fl::Rpc Class Reference

Detailed Description

Definition at line 178 of file rpc.h.

#include <rpc.h>

+ Collaboration diagram for fl::Rpc:

Classes

struct  Config
 Configuration for method registration with optional metadata. More...
 

Public Member Functions

 Rpc () FL_NOEXCEPT=default
 
 Rpc (const Rpc &) FL_NOEXCEPT=delete
 
 Rpc (Rpc &&) FL_NOEXCEPT=default
 
 ~Rpc () FL_NOEXCEPT=default
 
template<typename Callable>
void bind (const char *name, Callable fn, fl::RpcMode mode=fl::RpcMode::SYNC)
 Convenience overload: bind method by name, function, and optional mode.
 
template<typename Callable>
void bind (const Config< Callable > &config)
 Bind a method with configuration (name, function, optional metadata).
 
void bindAsync (const char *name, fl::function< void(ResponseSend &, const json &)> fn, fl::RpcMode mode=fl::RpcMode::ASYNC)
 Bind async method with ResponseSend& parameter (for ASYNC/ASYNC_STREAM modes) Signature: void(ResponseSend&, const json&) The ResponseSend& parameter is automatically injected with request ID and response sink The json& parameter contains the raw JSON params from the request.
 
void clear ()
 Clear all registered methods.
 
fl::size count () const
 Returns number of registered methods.
 
template<class Sig>
BindResult< Sig > get (const char *name) const
 Get a registered method by name.
 
json handle (const json &request)
 Process a JSON-RPC request.
 
fl::optional< jsonhandle_maybe (const json &request)
 For notifications (no id), returns nullopt.
 
bool has (const char *name) const
 Check if a method is registered (regardless of signature).
 
json methods () const
 Returns flat method array: [["name", "returnType", [["param1", "type1"], ...]], ...] Format: Array of method tuples optimized for low-memory devices.
 
Rpcoperator= (const Rpc &) FL_NOEXCEPT=delete
 
Rpcoperator= (Rpc &&) FL_NOEXCEPT=default
 
template<class Sig>
bool registerMethod (const char *name, RpcFn< Sig > fn, const fl::vector< fl::string > &paramNames, const fl::string &description, const fl::vector< fl::string > &tags, fl::RpcMode mode=fl::RpcMode::SYNC)
 
json schema () const
 Returns flat schema document.
 
void setResponseSink (fl::function< void(const fl::json &)> sink)
 Set response sink for sending ACK responses (used by async functions)
 
fl::vector< fl::stringtags () const
 Returns list of unique tags used across all methods.
 
bool unbind (const char *name)
 Unbind (unregister) a previously registered method.
 

Private Attributes

fl::unordered_map< fl::string, detail::RpcEntrymRegistry
 
fl::function< void(const fl::json &)> mResponseSink
 

The documentation for this class was generated from the following files: