You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to subscribe to a d-bus event and a d-bus property.
When I implement only one type of subscription all woks fine - I receive corresponding data via d-bus (a signal or a property data).
But when I try to use both (subscribe to a signal and to a property) I have the following troubles:
When the d-bus signal comes to the corresponding channel the same data also appears on the channel that is linked to the d-bus property. And vice versa.
This is my implementation of multi subscription:
`func TestSubs() {
// connect to the DBus
bus, err := dbus.SystemBus()
if err != nil {
log.Fatalf("error: dbus not connected. %s", err)
}
defer func() {
bus.Close()
}()
// subscribe to property
prop_ch := make(chan *dbus.Signal)
err = bus.AddMatchSignal(dbus.WithMatchObjectPath(dbusPath), dbus.WithMatchInterface(propIface), dbus.WithMatchMember(propMember))
if err != nil {
log.Fatalf("error: failed to subscribe to dbus property. %s", err)
}
bus.Signal(prop_ch)
// subscribe to event
event_ch := make(chan *dbus.Signal)
err = bus.AddMatchSignal(dbus.WithMatchObjectPath(dbusPath), dbus.WithMatchInterface(sigIface), dbus.WithMatchMember(sigMember))
if err != nil {
log.Fatalf("error: failed to subscribe to dbus event. %s", err)
}
bus.Signal(event_ch)
// poll received via d-bus data
for {
select {
case <-prop_ch:
fmt.Println("Property has been received via d-bus")
case <-event_ch:
fmt.Println("Signal has been received via d-bus")
default:
time.Sleep(50 * time.Millisecond)
}
}
}`
And there is the result that I get when a signal comes to the event_ch: Signal has been received via d-bus Property has been received via d-bus
Am I doing something wrong?
Kind regards,
Viacheslau
The text was updated successfully, but these errors were encountered:
That is the current expected behaviour of the library: the AddSignalMatch calls tell dbus-daemon what types of signal messages we're interested in, and the Signal calls set up channels that will receive all signals received from the bus.
We don't currently have a way to create a channel that will only receive signals matching a particular rule. I agree that it would be useful to add such a feature, but it is non-trivial to implement. In particular, WithMatchSender rules that use a well known bus name require that we track the ownership of that bus name, since matching signals will instead list the unique name as the sender (i.e. something like :1.42).
Hello.
I'm trying to subscribe to a d-bus event and a d-bus property.
When I implement only one type of subscription all woks fine - I receive corresponding data via d-bus (a signal or a property data).
But when I try to use both (subscribe to a signal and to a property) I have the following troubles:
When the d-bus signal comes to the corresponding channel the same data also appears on the channel that is linked to the d-bus property. And vice versa.
This is my implementation of multi subscription:
`func TestSubs() {
// connect to the DBus
bus, err := dbus.SystemBus()
if err != nil {
log.Fatalf("error: dbus not connected. %s", err)
}
}`
And there is the result that I get when a signal comes to the event_ch:
Signal has been received via d-bus Property has been received via d-bus
Am I doing something wrong?
Kind regards,
Viacheslau
The text was updated successfully, but these errors were encountered: