Skip to content

Commit

Permalink
Add Documentation for command (#106)
Browse files Browse the repository at this point in the history
Co-authored-by: Sebastian Feustel <sebastian.feustel@kdab.com>
  • Loading branch information
53845714nF and Sebastian Feustel authored May 14, 2024
1 parent 8358014 commit 18ab4db
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion lib/src/AnyRpcServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ AnyRpcServer::AnyRpcServer(int anyrpcPort)
utils::AddFunctionToAnyRpc<void()>(methodManager, "quit", "Close the app | quit()", [this] { quit(); });

utils::AddFunctionToAnyRpc<void(std::string, std::string)>(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);
Expand Down

0 comments on commit 18ab4db

Please sign in to comment.