我正在编写一个pydbus服务,我已经注册了一个接口并提供了一个类似
import pydbus
from pydbus import SessionBus
from gi.repository import GLib
class Server():
"""
<node>
<interface name="org.freedesktop.testSrv">
<method name="test">
<arg direction="in" type="s" name="testarg"/>
</method>
</interface>
</node>
"""
def test(testarg):
# here i want to access the sender id
print(testarg)
bus = SessionBus()
bus.publish("org.freedesktop.testSrv", Server())
loop = GLib.MainLoop()
loop.run()
当客户端调用此端点的方法时,我想知道源(发送方),它只执行函数test()
我知道dbus在请求中提供了这一点,例如 :.1.23 但是我没有找到一个用python访问这些信息的解决方案
您可以在方法签名中包含MethodCallContext(它是一个命名参数,因此必须是
dbus_context
):我不知道这是pydbus的实现细节还是API的一部分
相关问题 更多 >
编程相关推荐