[systemd-devel] sd_bus_message_new_signal
Salman Ahmed
salman.isd at gmail.com
Mon Jul 15 11:55:04 UTC 2019
Hello,
I am trying to send a signal using sdbus but I am not able to see anything
on my dbus-monitor command:
dbus-monitor "type='signal',interface='test.signal.Type'"
code:
sd_bus_error error = SD_BUS_ERROR_NULL;
sd_bus_message *m = NULL;
sd_bus *bus = NULL;
int r;
r = sd_bus_open_user(&bus);
if (r < 0) {
fprintf(stderr, "Failed to connect to user bus: %s\n", strerror(-r));
}
r= sd_bus_message_new_signal(bus, &m, "/test/signal/Object",
"test.signal.Type", "Test");
if (r < 0) {
fprintf(stderr, "new signal failed: %s\n", strerror(-r));
}
r = sd_bus_send(bus, m , NULL);
if (r < 0) {
fprintf(stderr, "bus send failed: %s\n", strerror(-r));
}
Sending a signal using libdbus like following works
conn = dbus_bus_get(DBUS_BUS_SESSION, &err);
msg = dbus_message_new_signal("/test/signal/Object", // object name of the
signal
"test.signal.Type", // interface name of the signal
"Test"); // name of the signal
if (!dbus_connection_send(conn, msg, &serial)) {
fprintf(stderr, "Out Of Memory!\n");
}
Any help would be appreciated.
Regards
Salman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20190715/de74341c/attachment.html>
More information about the systemd-devel
mailing list