Comments (7)
It's possible to have one thread listen and receive D-Bus calls and another thread handle them.
Your D-Bus thread would look like this (rough outline) :
for item in connection.iter() {
if let MethodCall(m) = item {
channel.send(m);
let reply = other_channel.recv();
for r in reply { connection.send(r); }
}
}
The main thread can either have a Tree
, and handling is then done by calling Tree.handle()
and the result back on the channel, or you can handle the message manually by calling methods on the message to figure out what message it is, and construct an appropriate reply using message.method_return().append(/* ... *)
.
Edit: minor fix to make example work with tree.handle()
from dbus-rs.
Could you elaborate a little on the Tree
way please?
from dbus-rs.
You would set up the Tree like in the server example but instead of calling tree.run
your code would look like (rough outline, add proper error handling) :
loop {
let msg = channel.recv();
let reply = tree.handle(msg);
other_channel.send(reply);
}
from dbus-rs.
Got another related question, how would I go about sending asynchronous signals?
Let's say I want to emit the signals directly from the main thread, is there a way to do it?
I was trying to put the Connection
into an Arc
but it's not Sync
and Send
and share the Arc<tree::Signal>
between the tree thread and the main thread, but I guess it wouldn't really work.
Any hints?
from dbus-rs.
The easiest way is to have two connections. I could see if I could make Connection
Send
, because I think it should be, but I doubt that will help much in your case.
There is also some stuff written about connection and thread safety in the API indicating that it could maybe even be Sync
. That would require some work on my part though as my wrapper currently isn't sync.
from dbus-rs.
Won't the register_name
explode because I'm overriding an already existing interface?
from dbus-rs.
Won't the register_name explode because I'm overriding an already existing interface?
You don't need to register a name to send signals, AFAIK?
from dbus-rs.
Related Issues (20)
- fdo ObjectManager GetManagedObjects method panics with multiple objects and async properties HOT 1
- "vendored" feature fails to compile HOT 7
- Possible deadlock in dbus-tokio HOT 4
- Crossroad example not working HOT 1
- `vendored` feature's build script writes outside of `$OUT_DIR` HOT 5
- async monitor? HOT 4
- monitor system bus without root privileges HOT 4
- [Help] When variant is a struct? HOT 10
- dbus-codegen: When crossroads is enabled, no client-side code is generated HOT 3
- dbus-codegen: Add attribute to specify rust type for method arguments HOT 4
- Annotations on interfaces not shown in introspection
- Any way to set uid in dbus authentication? HOT 6
- How to ensure that libdbus-sys compiles with X11 for dbus-daemon autolaunch on build HOT 4
- register object of type X on dbus? HOT 3
- pkg config failed HOT 1
- Async signal match not working HOT 2
- `dbus-codegen-rust` produces `#[deprecated]` annotations on trait implementations HOT 1
- Yank rbus-rs package on crates.io HOT 1
- Generated code from an XML file that only contains properties does not compile with crossroads HOT 4
- Make new `dbus-codegen` release
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dbus-rs.