User Tools

Site Tools


Network and communication


24.9.1 DBusObject

The (static) class DBusObject (gb.dbus) is the parent class for all objects that you can export to the D-Bus.

  • By default a (Gambas-)D-Bus object not automatically is exported to the D-Bus.
  • To export it, the two methods DBusConnection.Register(…) and DBusApplication.Connection.Register(…) are used. Example

Each method that you define in a Gambas D-Bus object inherits from the class DBusObject as the source code of TService.class shows:

' Gambas class file
Inherits DBusObject
Create Static
Public Function GetTemperature(Trigger As String) As RValue

For example, the source code in the file FMain.class declares a (gambas) D-Bus object of type TService and registers it on the Session D-Bus. If the server is terminated, the D-Bus object is logged off from the D-Bus, which the TService object made available to all d-bus-compatible applications for use.

' Gambas class file
Public hDBusObject As TService
Public Sub Form_Open()
  FMain.Resizable = False
  FMain.Caption = ("The data server is activated")
  DBus.Unique = True
  hDBusObject = New TService
  Try DBus.Session.Register(hDBusObject, "/TService")
  If Error Then
     Message.Error("An instance of " & Application.Name & " already exists.")
Public Sub Form_Close()
  If DBus.IsRegistered(hDBusObject) Then DBus.Session.Unregister(hDBusObject)

Two commented server projects can be found in chapters Project1 and Project2.


The website uses a temporary session cookie. This technically necessary cookie is deleted when the browser is closed. You can find information on cookies in our privacy policy.
k24/k24.9/k24.9.1/start.txt · Last modified: 02.07.2018 (external edit)

Page Tools