mvidner / ruby-dbus

A Ruby binding for DBus
GNU Lesser General Public License v2.1
170 stars 51 forks source link

Better support for monitoring DBus messages & example #92

Open nogweii opened 2 years ago

nogweii commented 2 years ago

It would be nice to have better support for monitoring/eavesdropping on messages sent across the bus. I have made a functional example but it requires a bit of monkey patching to change the library's behavior. This is the same functionality provided by the dbus-monitor(1) command.

  1. Support for another flag in match rules, though I'm not 100% certain it's needed for new enough implementations. I'm doing this to behave the same way dbus-monitor does.
  2. After calling BecomeMonitor, the socket becomes write-closed by the server. So the default behavior of #process no longer applies.

I think this is a useful feature, so I'd like to see this upstreamed. Not certain on the exact design though. A special #become_monitor method on DBus::Connection that re-uses the registered @signal_matchrules?

daveola commented 3 months ago

100% this.

And unfortunately the example nogweii wrote no longer seems to work because the internal monkey patching has gone stale, as monkey patching will do:

undefined method `service' for # (NoMethodError)