Gio.DBusConnection.prototype.call_sync
function call_sync(bus_name: String, object_path: String, interface_name: String, method_name: String, parameters: GLib.Variant, reply_type: GLib.VariantType, flags: Gio.DBusCallFlags, timeout_msec: Number(gint), cancellable: Gio.Cancellable): GLib.Variant { // Gjs wrapper for g_dbus_connection_call_sync() }
Synchronously invokes the method_name method on the interface_name D-Bus interface on the remote object at object_path owned by bus_name.
If connection is closed then the operation will fail with Gio.IOErrorEnum.closed. If cancellable is canceled, the operation will fail with Gio.IOErrorEnum.cancelled. If parameters contains a value not compatible with the D-Bus protocol, the operation fails with Gio.IOErrorEnum.invalid_argument.
If reply_type is non-null then the reply will be checked for having this type and an error will be raised if it does not match. Said another way, if you give a reply_type then any non-null return value will be of this type.
If the parameters GLib.Variant is floating, it is consumed. This allows convenient 'inline' use of GLib.Variant.new, e.g.: |[<!-- language="C" --> g_dbus_connection_call_sync (connection, "org.freedesktop.StringThings", "/org/freedesktop/StringThings", "org.freedesktop.StringThings", "TwoStrings", g_variant_new ("(ss)", "Thing One", "Thing Two"), NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); ]|
The calling thread is blocked until a reply is received. See Gio.DBusConnection.prototype.call for the asynchronous version of this method.
Since 2.26
- bus_name
a unique or well-known bus name or null if connection is not a message bus connection
- object_path
path of remote object
- interface_name
D-Bus interface to invoke method on
- method_name
the name of the method to invoke
- parameters
a GLib.Variant tuple with parameters for the method or null if not passing parameters
- reply_type
the expected type of the reply, or null
- flags
flags from the Gio.DBusCallFlags enumeration
- timeout_msec
the timeout in milliseconds, -1 to use the default timeout or %G_MAXINT for no timeout
- cancellable
a Gio.Cancellable or null
- Returns
null if @error is set. Otherwise a GLib.Variant tuple with return values. Free with GLib.Variant.prototype.unref.