Skip to content

Signals are not received (missing a call to dbus_bus_add_match?) #57

Description

@raphj

Hello,

Thanks for your library, it's very helpful. I'm trying to receive D-BUS signals. I'm using ddbus version 3.0.0-beta.1. My code looks like this:

void main() {
    Connection conn = connectToBus(DBusBusType.DBUS_BUS_SYSTEM);
    auto router = new MessageRouter();
    MessagePattern patt = MessagePattern(
        ObjectPath("/org/freedesktop/ModemManager1/Modem/0"),
        interfaceName("org.freedesktop.ModemManager1.Modem.Messaging"),
        "Added",
        true
    );

    router.setHandler!(void, ObjectPath, bool)(patt, (ObjectPath path, bool received) {
        writeln("Called with ", path, ", ", received);
    });

    registerRouter(conn, router);

    simpleMainLoop(conn);
}

I'm expecting to see Called with lines but I don't receive anything. I do, however, see such lines when I add this line before the call to router.setHandler:

dbus_bus_add_match(conn.conn, "type='signal',interface='org.freedesktop.ModemManager1.Modem.Messaging'", null);

I'm I doing something wrong?

For what it is worth, in ddbus's router.d, registerRouter registers a router like this:

void registerRouter(Connection conn, MessageRouter router) {
    void* routerP = cast(void*) router;
    GC.addRoot(routerP);
    dbus_connection_add_filter(conn.conn, &filterFunc, routerP, &unrootUserData);
}

I would expect to see calls to dbus_bus_add_match for each MessagePattern object added to the router. I can try to write a patch if needed.

By the way, I'm looking for a way to receive signals for any object that implement the given interface, I don't want to specify a particular source. dbus_bus_add_match and dbus_connection_add_filter allow this, but MessagePattern requires specifying an ObjectPath. Would it conceivable to allow specifying null in a MessagePattern?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions