DBusServer
Added in version 2.26.
Superclasses: Object
Implemented Interfaces: Initable
- Constructors:
DBusServer(**properties)
new_sync(address:str, flags:Gio.DBusServerFlags, guid:str, observer:Gio.DBusAuthObserver=None, cancellable:Gio.Cancellable=None) -> Gio.DBusServer
Constructors
- class DBusServer
- classmethod new_sync(address: str, flags: DBusServerFlags, guid: str, observer: DBusAuthObserver | None = None, cancellable: Cancellable | None = None) DBusServer
Creates a new D-Bus server that listens on the first address in
address
that works.Once constructed, you can use
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-
None
DBusAuthObserver
.Connect to the
DBusServer
::new-connection signal to handle incoming connections.The returned
DBusServer
isn’t active - you have to start it withstart()
.DBusServer
is used in this [example][gdbus-peer-to-peer].This is a synchronous failable constructor. There is currently no asynchronous version.
Added in version 2.26.
- Parameters:
address – A D-Bus address.
flags – Flags from the
DBusServerFlags
enumeration.guid – A D-Bus GUID.
observer – A
DBusAuthObserver
orNone
.cancellable – A
Cancellable
orNone
.
Methods
- class DBusServer
- get_client_address() str
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
DBusServer
succeeded.Added in version 2.26.
- get_flags() DBusServerFlags
Gets the flags for
server
.Added in version 2.26.
- get_guid() str
Gets the GUID for
server
, as provided tonew_sync()
.Added in version 2.26.
Properties
- class DBusServer
-
- props.authentication_observer: DBusAuthObserver
A
DBusAuthObserver
object to assist in the authentication process orNone
.Added in version 2.26.
- props.flags: DBusServerFlags
Flags from the
DBusServerFlags
enumeration.Added in version 2.26.
- props.guid: str
The GUID of the server.
See
DBusConnection
:guid for more details.Added in version 2.26.
Signals
- class DBusServer.signals
- new_connection(connection: DBusConnection) bool
Emitted when a new authenticated connection has been made. Use
get_peer_credentials()
to figure out what identity (if any), was authenticated.If you want to accept the connection, take a reference to the
connection
object and returnTrue
. When you are done with the connection callclose()
and give up your reference. Note that the other peer may disconnect at any time - a typical thing to do when accepting a connection is to listen to theDBusConnection
::closed signal.If
DBusServer
:flags containsRUN_IN_THREAD
then the signal is emitted in a new thread dedicated to the connection. Otherwise the signal is emitted in the [thread-default main context][g-main-context-push-thread-default] of the thread thatserver
was constructed in.You are guaranteed that signal handlers for this signal runs before incoming messages on
connection
are processed. This means that it’s suitable to callregister_object()
or similar from the signal handler.Added in version 2.26.
- Parameters:
connection – A
DBusConnection
for the new connection.