我们有一些自制应用程序在 Xubuntu 18.04 操作系统之上运行,使用 D-Bus 相互通信。 UI 部分在 Web 浏览器中运行,并且 Web 套接字用于与应用程序进行通信。
我们的目标是将每一次通信迁移到 D-Bus,但我尝试/org/freedesktop/DBus
从 chromium 浏览器访问以进行测试,但没有成功。我用了这个图书馆:
var dbus = require('dbus-native')
var conn = dbus.createConnection()
conn.message({
path: '/org/freedesktop/DBus',
destination: 'org.freedesktop.DBus',
'interface': 'org.freedesktop.DBus',
member: 'Hello',
type: dbus.messageType.methodCall
})
conn.on('message', function (msg) { console.log(msg) })
这是我在浏览器控制台中看到的:
Uncaught Error: unknown bus address
at createStream (index.js?26d9:22)
at Object.createConnection (index.js?26d9:76)
这是我在运行时看到的dbus-monitor
,但我不知道它是否与我的连接尝试有关:
signal time=1626258028.185483 sender=org.freedesktop.DBus -> destination=:1.196 serial=2 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameAcquired
string ":1.196"
signal time=1626258028.185641 sender=org.freedesktop.DBus -> destination=:1.196 serial=4 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameLost
string ":1.196"
method call time=1626258031.724118 sender=:1.195 -> destination=org.freedesktop.PowerManagement serial=7 path=/org/freedesktop/PowerManagement/Inhibit; interface=org.freedesktop.PowerManagement.Inhibit; member=UnInhibit
uint32 39
method return time=1626258031.724440 sender=:1.27 -> destination=:1.195 serial=151 reply_serial=7
method call time=1626258031.724721 sender=:1.195 -> destination=org.freedesktop.DBus serial=8 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=RemoveMatch
string "type='signal', path='/org/freedesktop/DBus/Local',interface='org.freedesktop.DBus.Local', member='Disconnected'"
method return time=1626258031.724743 sender=org.freedesktop.DBus -> destination=:1.195 serial=7 reply_serial=8
signal time=1626258031.725311 sender=org.freedesktop.DBus -> destination=:1.195 serial=5 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameLost
string ":1.195"
signal time=1626258031.725517 sender=org.freedesktop.DBus -> destination=(null destination) serial=339 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameOwnerChanged
string ":1.195"
string ":1.195"
string ""
是否可以通过 Web 浏览器访问 freedesktop DBus,或者我是否需要在 DBus 守护程序配置中进行一些调整才能允许它?我对 D-Bus 有点陌生。