hypfvieh / dbus-java

Improved version of java DBus library provided by freedesktop.org (https://dbus.freedesktop.org/doc/dbus-java/)
https://hypfvieh.github.io/dbus-java/
MIT License
180 stars 72 forks source link

How to send dbus-send command using library #219

Closed nihasmata closed 1 year ago

nihasmata commented 1 year ago

How to send following dbus-send command via this library. I didn't find so much example for such a usage. Could you help me ?

dbus-send --bus=tcp:host=10.0.5.161,port=2334 --type=method_call --dest=org.mpris.MediaPlayer2.vlc /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Play

hypfvieh commented 1 year ago

This is basically the same question you asked in #217. The answer is still the same: You need to create the interface classes for VLC using the code generator.

You don't send arbitrary commands using dbus-java, you communicate using proxy objects. To allow Java to create proper proxy objects you need the interface classes.

Using dbus-java is demonstrated in various examples in the dbus-java-examples modules and in various unit tests found in dbus-java-test. It doesn't matter if you use TCP or unix socket as connection (aka transport), the only difference is creating the connection as I've already described in #217.

I will close this issue as this is a duplicate of #217 in my eyes.