Comments (7)
The problem is that no event loop was run in your example for the connection
. One must call enterEventLoop()
or enterEventLoopAsync()
method of the connection
object. Perhaps that is not specified clearly in the sdbus-c++ tutorial...
from sdbus-cpp.
Or you can simply create sessionResponse
like this: auto sessionResponse = sdbus::createProxy(sdbus::createSessionBusConnection(), destinationName, sessionResponsePath);
, which, according to https://github.com/Kistler-Group/sdbus-cpp/blob/master/docs/using-sdbus-c%2B%2B.md#using-d-bus-connections-on-the-client-side means that the proxy will get an owner of the connection and will automatically run the event loop on it for your convenience (hence signals would work fine for you), and create createSession
like this: auto createSession = sdbus::createProxy(sdbus::createSessionBusConnection(), destinationName, objectPath, sdbus::dont_run_event_loop_thread);
, which has the proxy create another connection, but whose event loop would not be run because you just use it to call a method and then let go of it, as described again in https://github.com/Kistler-Group/sdbus-cpp/blob/master/docs/using-sdbus-c%2B%2B.md#using-d-bus-connections-on-the-server-side, so this saves time and resources.
from sdbus-cpp.
That was quick, thanks. I only looked at the client side of the tutorials. Now I see and it works.
from sdbus-cpp.
Out of curiosity, how does this example look in rust with the zbus library? Can you paste the code? I wonder if I can simplify anything here :-)
from sdbus-cpp.
Very similar but with more macro magic. main.txt
The official example is probably more helpful than my code: https://dbus2.github.io/zbus/client.html
from sdbus-cpp.
I like that zbus can deserialize 'a{sv}' into structs instead of maps. https://dbus2.github.io/zbus/faq.html
I think this feature fits cpp just as well.
from sdbus-cpp.
@FuchtelJockel I think that would be possible in sdbus-c++, too. The user would, however, need to additionally describe his struct (through some sort of sdbus-c++-provided macros, for example) so that sdbus-c++ would know understand the struct's members, their names, position etc.
I may add this to my TODO list.
from sdbus-cpp.
Related Issues (20)
- Build system fails to detect elogind HOT 1
- sdbus-cpp can not receive PrepareForSleep signal HOT 2
- Building statically but linking to a shared library results in linker error HOT 2
- CanCallMethodSynchronouslyWithoutAnEventLoopThread hangs since 1.3.0 if built by Clang HOT 8
- Disable sd-event in release/v2.0 once #358 is merged and release/v2.0 rebased HOT 2
- Support for creating tcp connections via sd_bus_set_address or sd_bus_set_fd HOT 2
- pkgconfig fails to resolve dependencies
- Tests installation path should respect install prefix
- Allow moving ProxyInterfaces HOT 2
- Error when implementing ObjectManager on System Bus Connection
- Sporadic missed NameAcquired signal if requestName called after enterEventLoopAsync HOT 2
- Serialization of maps into structs and vice versa
- Manually configuring choice of sd-bus implementation library HOT 4
- [org.freedesktop.DBus.Error.ServiceUnknown] The name com.example.test was not provided by any .service files HOT 5
- why: uncaught exception of type sdbus::Error ([org.freedesktop.DBus.Error.FileNotFound] Failed to open bus (No such file or directory)) HOT 1
- Crash when running a connection event loop HOT 2
- How to do IPC between two process by sdbus::createServerBus and sdbus::createDirectBusConnection
- Allow arbitrary structs in an sdbus interface HOT 4
- Support for serializing `std::variant<>` types HOT 2
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 sdbus-cpp.