Client


Description:

[ CCode ( has_construct_function = false ) ]
public Client (Cancellable? cancellable = null) throws Error

Creates a new Client synchronously.

Note that this will block until a NMClient instance is fully initialized. This does nothing beside calling @new. You are free to call @new or @new/g_initable_init() directly for more control, to set GObject properties or get access to the NMClient instance while it is still initializing.

Using the synchronous initialization creates an Client instance that uses an internal MainContext. This context is invisible to the user. This introduces an additional overhead that is payed not only during object initialization, but for the entire lifetime of this object. Also, due to this internal MainContext , the events are no longer in sync with other messages from DBusConnection (but all events of the NMClient will themselves still be ordered). For a serious program, you should therefore avoid these problems by using init_async or new_async instead. The sync initialization is still useful for simple scripts or interactive testing for example via pygobject.

Creating an Client instance can only fail for two reasons. First, if you didn't provide a nm_client_dbus_connection and the call to @get fails. You can avoid that by using @new directly and set a D-Bus connection. Second, if you cancelled the creation. If you do that, then note that after the failure there might still be idle actions pending which keep get_main_context alive. That means, in that case you must continue iterating the context to avoid leaks. See get_context_busy_watcher.

Creating an Client instance when NetworkManager is not running does not cause a failure.

Parameters:

cancellable

a Cancellable, or null

Returns:

a new Client or NULL on an error




2022 vala-language.org