From 8ce61e4e20a11fbb605cd29f07a820213dbcf91e Mon Sep 17 00:00:00 2001 From: Vernon Mauery Date: Tue, 28 Aug 2018 08:54:59 -0700 Subject: Allow callback raw access to message In some cases, the callback may care where the message came from. Allow the callback to receive the raw sdbusplus::message along with the automatically extracted arguments. This means that the registration mechanism as well as the callback mechanism need to be aware of a 'message as a first parameter' situation and behave accordingly. The registration needs to strip the message parameter off in order to expose a correct DBus signature. The callback mechanism needs to strip of the message parameter in order to properly unpack the message, but add it back in before calling apply to execute the function. Tested: Added an example to example/asio-example.cpp and checked to see that it builds. Was able to extract sender from message passed into the IPMI handler. Change-Id: I520e494d3baad34271e748465f30274353554728 Signed-off-by: Vernon Mauery --- example/asio-example.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'example/asio-example.cpp') diff --git a/example/asio-example.cpp b/example/asio-example.cpp index 82d713e..7477357 100644 --- a/example/asio-example.cpp +++ b/example/asio-example.cpp @@ -12,6 +12,11 @@ int foo(int test) return ++test; } +int methodWithMessage(sdbusplus::message::message& m, int test) +{ + return ++test; +} + int main() { using GetSubTreeType = std::vectorregister_method("TestFunction", foo); + iface->register_method("TestMethodWithMessage", methodWithMessage); + iface->initialize(); iface->set_property("int", 45); io.run(); -- cgit v1.2.3