summaryrefslogtreecommitdiffstats
path: root/example
diff options
context:
space:
mode:
authorVernon Mauery <vernon.mauery@linux.intel.com>2018-08-28 08:54:59 -0700
committerVernon Mauery <vernon.mauery@linux.intel.com>2018-08-28 11:17:02 -0700
commit8ce61e4e20a11fbb605cd29f07a820213dbcf91e (patch)
tree5c2d07a39b5d8be2bb1192b8a73de47b733ec4e3 /example
parent387110bdf265b5c4435b740aed7e24c3975c514b (diff)
downloadsdbusplus-8ce61e4e20a11fbb605cd29f07a820213dbcf91e.tar.gz
sdbusplus-8ce61e4e20a11fbb605cd29f07a820213dbcf91e.zip
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 <vernon.mauery@linux.intel.com>
Diffstat (limited to 'example')
-rw-r--r--example/asio-example.cpp8
1 files changed, 7 insertions, 1 deletions
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::vector<std::pair<
@@ -60,7 +65,6 @@ int main()
{
std::cout << item.first << "\n";
}
-
},
"xyz.openbmc_project.ObjectMapper",
"/xyz/openbmc_project/object_mapper",
@@ -115,6 +119,8 @@ int main()
iface->register_method("TestFunction", foo);
+ iface->register_method("TestMethodWithMessage", methodWithMessage);
+
iface->initialize();
iface->set_property("int", 45);
io.run();
OpenPOWER on IntegriCloud