Skip to content

Commit

Permalink
Add Documentation for command
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Feustel committed Mar 13, 2024
1 parent 1508416 commit 636975b
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 @@ -102,7 +102,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 636975b

Please sign in to comment.