Class: Gio::DBusServer

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

Overview

GDBusServer 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 [funcGio.bus_own_name].

An example of peer-to-peer communication with GDBus can be found in gdbus-example-peer.c.

Note that a minimal GDBusServer will accept connections from any peer. In many use-cases it will be necessary to add a [classGio.DBusAuthObserver] that only accepts connections that have successfully authenticated as the same user that is running the GDBusServer. Since GLib 2.68 this can be achieved more simply by passing the G_DBUS_SERVER_FLAGS_AUTHENTICATION_REQUIRE_SAME_USER flag to the server.

Instance Method Summary collapse

Constructor Details

#initialize(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][gdbus-peer-to-peer].

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

Parameters:

Instance Method Details

#active=(active) ⇒ Boolean

Whether the server is currently active.

Parameters:

  • active (Boolean)

Returns:

  • (Boolean)

    active

  • (Boolean)

    active

#active?Boolean

Whether the server is currently active.

Returns:

  • (Boolean)

    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.

See GDBus::Connection:guid for more details.

Returns:

  • (String)

    guid

#guid=(guid) ⇒ String

The GUID of the server.

See GDBus::Connection:guid for more details.

Parameters:

  • guid (String)

Returns:

  • (String)

    guid

  • (String)

    guid

#is_activeBoolean

Gets whether server is active.

Returns:

  • (Boolean)

    true if server is active, false otherwise.

#startnil

Starts server.

Returns:

  • (nil)

#stopnil

Stops server.

Returns:

  • (nil)