Gio.DBusConnection
const Gio = imports.gi.Gio; let dBusConnection = new Gio.DBusConnection({ address: value, authentication_observer: value, flags: value, guid: value, stream: value, });
The Gio.DBusConnection type is used for D-Bus connections to remote peers such as a message buses. It is a low-level API that offers a lot of flexibility. For instance, it lets you establish a connection over any transport that can by represented as an Gio.IOStream.
This class is rarely used directly in D-Bus clients. If you are writing an D-Bus client, it is often easier to use the Gio.bus_own_name, Gio.bus_watch_name or Gio.DBusProxy.new_for_bus APIs.
As an exception to the usual GLib rule that a particular object must not be used by two threads at the same time, Gio.DBusConnection's methods may be called from any thread. This is so that Gio.bus_get and Gio.bus_get_sync can safely return the same Gio.DBusConnection when called from any thread.
Most of the ways to obtain a Gio.DBusConnection automatically initialize it (i.e. connect to D-Bus): for instance, Gio.DBusConnection.new and Gio.bus_get, and the synchronous versions of those methods, give you an initialized connection. Language bindings for GIO should use Gio.Initable.new or Gio.AsyncInitable.new_async, which also initialize the connection.
If you construct an uninitialized Gio.DBusConnection, such as via GObject.Object.new, you must initialize it via Gio.Initable.prototype.init or Gio.AsyncInitable.prototype.init_async before using its methods or properties. Calling methods or accessing properties on a Gio.DBusConnection that has not completed initialization successfully is considered to be invalid, and leads to undefined behaviour. In particular, if initialization fails with a GLib.Error, the only valid thing you can do with that Gio.DBusConnection is to free it with GObject.Object.prototype.unref.
## An example D-Bus server # {#gdbus-server}
Here is an example for a D-Bus server: [gdbus-example-server.c](https://git.gnome.org/browse/glib/tree/gio/tests/gdbus-example-server.c)
## An example for exporting a subtree # {#gdbus-subtree-server}
Here is an example for exporting a subtree: [gdbus-example-subtree.c](https://git.gnome.org/browse/glib/tree/gio/tests/gdbus-example-subtree.c)
## An example for file descriptor passing # {#gdbus-unix-fd-client}
Here is an example for passing UNIX file descriptors: [gdbus-unix-fd-client.c](https://git.gnome.org/browse/glib/tree/gio/tests/gdbus-unix-fd-client.c)
## An example for exporting a GObject # {#gdbus-export}
Here is an example for exporting a GObject.Object: [gdbus-example-export.c](https://git.gnome.org/browse/glib/tree/gio/tests/gdbus-example-export.c)
Since 2.26
Hierarchy
-
GObject.Object
- Gio.DBusConnection
Methods
- Gio.DBusConnection.prototype.add_filter
- Gio.DBusConnection.prototype.call
- Gio.DBusConnection.prototype.call_finish
- Gio.DBusConnection.prototype.call_sync
- Gio.DBusConnection.prototype.call_with_unix_fd_list
- Gio.DBusConnection.prototype.call_with_unix_fd_list_finish
- Gio.DBusConnection.prototype.call_with_unix_fd_list_sync
- Gio.DBusConnection.prototype.close
- Gio.DBusConnection.prototype.close_finish
- Gio.DBusConnection.prototype.close_sync
- Gio.DBusConnection.prototype.emit_signal
- Gio.DBusConnection.prototype.export_action_group
- Gio.DBusConnection.prototype.export_menu_model
- Gio.DBusConnection.prototype.flush
- Gio.DBusConnection.prototype.flush_finish
- Gio.DBusConnection.prototype.flush_sync
- Gio.DBusConnection.prototype.get_capabilities
- Gio.DBusConnection.prototype.get_exit_on_close
- Gio.DBusConnection.prototype.get_guid
- Gio.DBusConnection.prototype.get_last_serial
- Gio.DBusConnection.prototype.get_peer_credentials
- Gio.DBusConnection.prototype.get_stream
- Gio.DBusConnection.prototype.get_unique_name
- Gio.DBusConnection.prototype.is_closed
- Gio.DBusConnection.prototype.register_object
- Gio.DBusConnection.prototype.register_subtree
- Gio.DBusConnection.prototype.remove_filter
- Gio.DBusConnection.prototype.send_message
- Gio.DBusConnection.prototype.send_message_with_reply
- Gio.DBusConnection.prototype.send_message_with_reply_finish
- Gio.DBusConnection.prototype.send_message_with_reply_sync
- Gio.DBusConnection.prototype.set_exit_on_close
- Gio.DBusConnection.prototype.signal_subscribe
- Gio.DBusConnection.prototype.signal_unsubscribe
- Gio.DBusConnection.prototype.start_message_processing
- Gio.DBusConnection.prototype.unexport_action_group
- Gio.DBusConnection.prototype.unexport_menu_model
- Gio.DBusConnection.prototype.unregister_object
- Gio.DBusConnection.prototype.unregister_subtree