Shouqun / node-dbus

dbus module for node
MIT License
150 stars 70 forks source link

DBus.getBus() Can Only Be Called Once #240

Open bkeller7777 opened 2 years ago

bkeller7777 commented 2 years ago

I wanted to add a DBus.getBus('session').getInterface() retry mechanism such that if a call to getInterface() fails it would periodically retry. I found that in my initial implementation if getInterface() failed once (with Error: No introspectable) that it would always fail, even if the interface in question was instantiated later on. In my initial implementation I would call DBus.getBus('session') every attempt to get the interface. I was able to get around this issue by only calling DBus.getBus('session') once in my application. Afterwards, getInterface() would succeed on a retry attempt after it previously failed once the external interface was instantiated.

I have also found that this issue of only being able to execute DBus.getBus() once limits you to only be able to call DBus.getBus() OR DBus.registerService() once; you can only call one or the other in your application. The reason I think is because DBus.getBus() is called within DBus.registerService(). So the only way I've found to be able to create an interface and acquire an interface within the same application is if you launch one or the other within a child process.