diff --git a/README.md b/README.md index 5221325..207dac6 100644 --- a/README.md +++ b/README.md @@ -231,6 +231,27 @@ s.invokeMethod("root/item", "test", [34]) s.invokeMethod("root/item", "test", [{}]) ``` +### Using generic/custom command +You can register your own commands in your C++ Application. +It could be useful for Example to reset your hole Application. + +Register the Commands in your C++ Code: +```C++ + ... + spix::AnyRpcServer server; + server.setGenericCommandHandler([](std::string command, std::string payload) { + // do whatever needs to be done + }); + ... +``` +Now you have all capabilities that the Application has. +The Payload handling must be done by your own. + +You can call this in Python like this: +```python +s.command('reset', 'now') +``` + ## Two modes of operation In general, Spix can be used in two ways, which are different in how events are generated and sent to your application: diff --git a/lib/src/AnyRpcServer.cpp b/lib/src/AnyRpcServer.cpp index 4551daf..e5cdcb3 100644 --- a/lib/src/AnyRpcServer.cpp +++ b/lib/src/AnyRpcServer.cpp @@ -102,7 +102,7 @@ AnyRpcServer::AnyRpcServer(int anyrpcPort) utils::AddFunctionToAnyRpc(methodManager, "quit", "Close the app | quit()", [this] { quit(); }); utils::AddFunctionToAnyRpc(methodManager, "command", - "Executes a generic command | command(string command, string payload)", + "Executes a generic/custom command | command(string command, string payload)", [this](std::string command, std::string payload) { genericCommand(command, payload); }); m_pimpl->server->BindAndListen(anyrpcPort);