Class: Gio::DBusServer

Inherits:
Object
  • Object
show all
Defined in:
(unknown)

Overview

GDBus::Server is a helper for listening to and accepting D-Bus connections. This can be used to create a new D-Bus server, allowing two peers to use the D-Bus protocol for their own specialized communication. A server instance provided in this way will not perform message routing or implement the org.freedesktop.DBus interface.

To just export an object on a well-known name on a message bus, such as the session or system bus, you should instead use g_bus_own_name().

An example of peer-to-peer communication with G-DBus can be found in [gdbus-example-peer.c](git.gnome.org/browse/glib/tree/gio/tests/gdbus-example-peer.c).

Note that a minimal GDBus::Server will accept connections from any peer. In many use-cases it will be necessary to add a GDBus::AuthObserver that only accepts connections that have successfully authenticated as the same user that is running the GDBus::Server.

Instance Method Summary collapse

Instance Method Details

#active=(active) ⇒ TrueClass

Whether the server is currently active.

Parameters:

  • active (TrueClass)

Returns:

  • (TrueClass)

    active

  • (TrueClass)

    active

#active?TrueClass

Whether the server is currently active.

Returns:

  • (TrueClass)

    active

#addressString

The D-Bus address to listen on.

Returns:

  • (String)

    address

#address=(address) ⇒ String

The D-Bus address to listen on.

Parameters:

  • address (String)

Returns:

  • (String)

    address

  • (String)

    address

#authentication_observerGio::DBusAuthObserver

A GDBus::AuthObserver object to assist in the authentication process or nil.

Returns:

#authentication_observer=(authentication_observer) ⇒ Gio::DBusAuthObserver

A GDBus::AuthObserver object to assist in the authentication process or nil.

Parameters:

Returns:

#client_addressString

The D-Bus address that clients can use.

Returns:

  • (String)

    client-address

#client_address=(client_address) ⇒ String

The D-Bus address that clients can use.

Parameters:

  • client_address (String)

Returns:

  • (String)

    client-address

  • (String)

    client-address

#flagsGio::DBusServerFlags

Flags from the GDBus::ServerFlags enumeration.

Returns:

#flags=(flags) ⇒ Gio::DBusServerFlags

Flags from the GDBus::ServerFlags enumeration.

Parameters:

Returns:

#guidString

The guid of the server.

Returns:

  • (String)

    guid

#guid=(guid) ⇒ String

The guid of the server.

Parameters:

  • guid (String)

Returns:

  • (String)

    guid

  • (String)

    guid

#is_activeTrueClass

Gets whether server is active.

Returns:

  • (TrueClass)

    true if server is active, false otherwise.

#new_sync(address, flags, guid, observer, cancellable) ⇒ Gio::DBusServer

Creates a new D-Bus server that listens on the first address in address that works.

Once constructed, you can use g_dbus_server_get_client_address() to get a D-Bus address string that clients can use to connect.

To have control over the available authentication mechanisms and the users that are authorized to connect, it is strongly recommended to provide a non-nil GDBus::AuthObserver.

Connect to the GDBus::Server::new-connection signal to handle incoming connections.

The returned GDBus::Server isn’t active - you have to start it with g_dbus_server_start().

GDBus::Server is used in this [example].

This is a synchronous failable constructor. There is currently no asynchronous version. g_object_unref().

Parameters:

Returns:

#startnil

Starts server.

Returns:

  • (nil)

#stopnil

Stops server.

Returns:

  • (nil)