class Gio::DBusServer
- Gio::DBusServer
- GObject::Object
- Reference
- Object
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 g_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 #GDBusAuthObserver 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.
Included Modules
Defined in:
lib/gi-crystal/src/auto/gio-2.0/d_bus_server.crConstructors
-
.new
Initialize a new
DBusServer
. - .new(*, active : Bool? = nil, address : String? = nil, authentication_observer : Gio::DBusAuthObserver? = nil, client_address : String? = nil, flags : Gio::DBusServerFlags? = nil, guid : String? = nil)
-
.new_sync(address : String, flags : Gio::DBusServerFlags, guid : String, observer : Gio::DBusAuthObserver?, cancellable : Gio::Cancellable?) : self
Creates a new D-Bus server that listens on the first address in @address that works.
Class Method Summary
-
.g_type : UInt64
Returns the type id (GType) registered in GLib type system.
Instance Method Summary
- #active? : Bool
- #address : String
- #address=(value : String) : String
- #authentication_observer : Gio::DBusAuthObserver?
- #authentication_observer=(value : Gio::DBusAuthObserver?) : Gio::DBusAuthObserver?
-
#client_address : String
Gets a D-Bus address string that can be used by clients to connect to @server.
-
#flags : Gio::DBusServerFlags
Gets the flags for @server.
- #flags=(value : Gio::DBusServerFlags) : Gio::DBusServerFlags
-
#guid : String
Gets the GUID for @server, as provided to g_dbus_server_new_sync().
- #guid=(value : String) : String
-
#is_active : Bool
Gets whether @server is active.
- #new_connection_signal
-
#start : Nil
Starts @server.
-
#stop : Nil
Stops @server.
Instance methods inherited from module Gio::Initable
init(cancellable : Gio::Cancellable?) : Bool
init,
newv(object_type : UInt64, parameters : Enumerable(GObject::Parameter), cancellable : Gio::Cancellable?) : GObject::Object
newv,
to_unsafe
to_unsafe
Class methods inherited from module Gio::Initable
g_type : UInt64
g_type
Instance methods inherited from class GObject::Object
bind_property(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags) : GObject::Binding
bind_property,
bind_property_full(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags, transform_to : GObject::Closure, transform_from : GObject::Closure) : GObject::Binding
bind_property_full,
data(key : String) : Pointer(Void)?
data,
finalize
finalize,
freeze_notify : Nil
freeze_notify,
getv(names : Enumerable(String), values : Enumerable(_)) : Nil
getv,
notify(property_name : String) : Nil
notify,
notify_by_pspec(pspec : GObject::ParamSpec) : Nil
notify_by_pspec,
notify_signal
notify_signal,
property(property_name : String, value : _) : Nil
property,
qdata(quark : UInt32) : Pointer(Void)?
qdata,
ref_count : UInt32
ref_count,
run_dispose : Nil
run_dispose,
set_data(key : String, data : Pointer(Void)?) : Nil
set_data,
set_property(property_name : String, value : _) : Nil
set_property,
steal_data(key : String) : Pointer(Void)?
steal_data,
steal_qdata(quark : UInt32) : Pointer(Void)?
steal_qdata,
thaw_notify : Nil
thaw_notify,
to_unsafe : Pointer(Void)
to_unsafe,
watch_closure(closure : GObject::Closure) : Nil
watch_closure
Constructor methods inherited from class GObject::Object
cast(obj : GObject::Object) : self
cast,
cast?(obj : GObject::Object) : self?
cast?,
new(pointer : Pointer(Void), transfer : GICrystal::Transfer)new new, newv(object_type : UInt64, parameters : Enumerable(GObject::Parameter)) : self newv
Class methods inherited from class GObject::Object
compat_control(what : UInt64, data : Pointer(Void)?) : UInt64
compat_control,
g_type : UInt64
g_type,
interface_find_property(g_iface : GObject::TypeInterface, property_name : String) : GObject::ParamSpec
interface_find_property,
interface_list_properties(g_iface : GObject::TypeInterface) : Enumerable(GObject::ParamSpec)
interface_list_properties
Constructor Detail
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
#GDBusAuthObserver.
Connect to the #GDBusServer::new-connection signal to handle incoming connections.
The returned #GDBusServer isn't active - you have to start it with g_dbus_server_start().
#GDBusServer is used in this [example][gdbus-peer-to-peer].
This is a synchronous failable constructor. There is currently no asynchronous version.
Class Method Detail
Instance Method Detail
Gets a D-Bus address string that can be used by clients to connect to @server.
This is valid and non-empty if initializing the #GDBusServer succeeded.