Proxy

interface Proxy : Resource

Represents a proxy object, which is a convenient local object created to represent a remote D-Bus object in another process. The proxy enables calling methods on remote objects, receiving signals from remote objects, and getting/setting properties of remote objects.

All Proxy member methods throw com.monkopedia.sdbus.SdbusException in case of D-Bus or sdbus-kotlin error. The Proxy interface has been designed as thread-aware. However, the operation of creating and sending method calls (both synchronously and asynchronously) is thread-safe by design.

Properties

Link copied to clipboard
abstract val connection: Connection

Provides D-Bus connection used by the proxy

Link copied to clipboard

Provides access to the currently processed D-Bus message

Link copied to clipboard
abstract val objectPath: ObjectPath

Returns object path of the underlying DBus object

Functions

Link copied to clipboard
abstract fun callMethod(message: MethodCall): MethodReply
abstract fun callMethod(message: MethodCall, timeout: Duration): MethodReply

Calls method on the remote D-Bus object

Link copied to clipboard
inline fun <R : Any> Proxy.callMethod(interfaceName: InterfaceName, methodName: MethodName, builder: MethodInvoker.() -> Unit): R

Calls method on the D-Bus object

Link copied to clipboard
abstract suspend fun callMethodAsync(message: MethodCall): MethodReply

Calls method on the D-Bus object asynchronously

abstract suspend fun callMethodAsync(message: MethodCall, timeout: Duration): MethodReply

Calls method on the D-Bus object asynchronously, with custom timeout

Link copied to clipboard
inline suspend fun <R : Any> Proxy.callMethodAsync(interfaceName: InterfaceName, methodName: MethodName, builder: MethodInvoker.() -> Unit): R

Calls method on the D-Bus object asynchronously

Link copied to clipboard
open override fun close()

Closes this resource by delegating to release, enabling use with use { }.

Link copied to clipboard
abstract fun createMethodCall(interfaceName: InterfaceName, methodName: MethodName): MethodCall

Creates a method call message

Link copied to clipboard

Gets values of all properties of the D-Bus object

Gets the values of all properties declared on the given interface.

Link copied to clipboard

Gets values of all properties of the D-Bus object asynchronously

Asynchronously gets the values of all properties declared on the given interface.

Link copied to clipboard
inline fun <T : Any> Proxy.getProperty(interfaceName: InterfaceName, propertyName: PropertyName): T

Gets value of a property of the D-Bus object

Link copied to clipboard

Gets value of a property of the D-Bus object asynchronously

inline suspend fun <T : Any> Proxy.getPropertyAsync(interfaceName: InterfaceName, propertyName: PropertyName): T

Asynchronously gets the value of a property of the D-Bus object.

Link copied to clipboard
inline fun <R, T : Any> Proxy.mutableDelegate(interfaceName: InterfaceName, propertyName: PropertyName): MutablePropertyDelegate<R, T>

Creates a read/write Kotlin property delegate backed by a D-Bus property.

Link copied to clipboard
inline fun Proxy.onSignal(interfaceName: InterfaceName, signalName: SignalName, builder: SignalSubscriber.() -> Unit): Resource

Registers a signal handler for a given signal of the D-Bus object

Link copied to clipboard
inline fun <R, T : Any> Proxy.prop(interfaceName: InterfaceName, propertyName: PropertyName): ReadWriteProperty<R, T>

Creates a simple read/write Kotlin property delegate backed by a D-Bus property.

Link copied to clipboard
inline fun <R, T : Any> Proxy.propDelegate(interfaceName: InterfaceName, propertyName: PropertyName): PropertyDelegate<R, T>

Creates a read-only Kotlin property delegate backed by a D-Bus property.

Link copied to clipboard
abstract fun registerSignalHandler(interfaceName: InterfaceName, signalName: SignalName, signalHandler: SignalHandler): Resource

Registers a handler for the desired signal emitted by the D-Bus object

Link copied to clipboard
abstract fun release()

Releases this resource and any child resources it may have.

Link copied to clipboard
inline fun <T : Any> Proxy.setProperty(interfaceName: InterfaceName, propertyName: PropertyName, value: T, dontExpectReply: Boolean = false)

Sets a property on the D-Bus object.

Link copied to clipboard

Sets value of a property of the D-Bus object asynchronously

inline suspend fun <T : Any> Proxy.setPropertyAsync(interfaceName: InterfaceName, propertyName: PropertyName, value: T, dontExpectReply: Boolean = false)

Asynchronously sets a property on the D-Bus object.

Link copied to clipboard
inline fun <T> Proxy.signalFlow(interfaceName: InterfaceName, signalName: SignalName, builder: SignalSubscriber.() -> Unit): Flow<T>

Subscribes to a D-Bus signal and exposes its decoded payloads as a cold Flow.