sdbus++: async: server: generate method-call fn
Add binding generation for method-call functions.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I34ac44ae0cdb43a18b96a4ddc5e67df4971da939
diff --git a/example/calculator-aserver.cpp b/example/calculator-aserver.cpp
index 149da86..6dc8579 100644
--- a/example/calculator-aserver.cpp
+++ b/example/calculator-aserver.cpp
@@ -28,6 +28,27 @@
return false;
}
+ auto method_call(multiply_t, auto x, auto y)
+ {
+ auto r = x * y;
+ last_result(r);
+ return r;
+ }
+
+ auto method_call(divide_t, auto x, auto y)
+ -> sdbusplus::async::task<divide_t::return_type>
+ {
+ auto r = x / y;
+ last_result(r);
+ co_return r;
+ }
+
+ auto method_call(clear_t) -> sdbusplus::async::task<>
+ {
+ last_result(0);
+ co_return;
+ }
+
private:
auto startup() -> sdbusplus::async::task<>
{
@@ -36,7 +57,7 @@
status(State::Error);
- while (1)
+ while (!ctx.stop_requested())
{
using namespace std::literals;
co_await sdbusplus::async::sleep_for(ctx, 10s);