Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
raphj opened this issue Aug 6, 2021 · 0 comments
Open

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

raphj opened this issue Aug 6, 2021 · 0 comments

Comments

@raphj
Copy link

raphj commented Aug 6, 2021

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant