1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-16 00:00:07 +01:00
libwebsockets/minimal-examples/dbus-server/minimal-dbus-server
Andy Green b3131fdfdd cmakelist: Augean Stables refactor
Establish a new distributed CMake architecture with CMake code related to
a source directory moving to be in the subdir in its own CMakeLists.txt.
In particular, there's now one in ./lib which calls through to ones
further down the directory tree like ./lib/plat/xxx, ./lib/roles/xxx etc.

This cuts the main CMakelists.txt from 98KB -> 33KB, about a 66% reduction,
and it's much easier to maintain sub-CMakeLists.txt that are in the same
directory as the sources they manage, and conceal all the details that that
level.

Child CMakelists.txt become responsible for:

 - include_directories() definition (this is not supported by CMake
   directly, it passes it back up via PARENT_SCOPE vars in helper
   macros)

 - Addition child CMakeLists.txt inclusion, for example toplevel ->
   role -> role subdir

 - Source file addition to the build

 - Dependent library path resolution... this is now a private thing
   in the child CMakeLists.txt, it just passes back any adaptations
   to include_directories() and the LIB_LIST without filling the
   parent namespace with the details
2020-05-27 08:40:12 +01:00
..
CMakeLists.txt cmakelist: Augean Stables refactor 2020-05-27 08:40:12 +01:00
main.c sul: all timed objects use a single pt sul list 2019-08-09 10:12:09 +01:00
README.md role: dbus 2018-10-13 08:16:27 +08:00

lws minimal dbus server

build

Using libdbus requires additional non-default include paths setting, same as is necessary for lws build described in ./lib/roles/dbus/README.md

CMake can guess one path and the library name usually, see the README above for details of how to override for custom libdbus and cross build.

Fedora example:

$ cmake .. -DLWS_DBUS_INCLUDE2="/usr/lib64/dbus-1.0/include"
$ make

Ubuntu example:

$ cmake .. -DLWS_DBUS_INCLUDE2="/usr/lib/x86_64-linux-gnu/dbus-1.0/include"
$ make

usage

Commandline option Meaning
-d Debug verbosity in decimal, eg, -d15
--session Bind to session bus instead of creating private abstract unix socket

By default the minimal server listens using its own abstract unix socket at unix:abstract=org.libwebsockets.test.

You can also run it instead as a participant on the session bus, without its own unix socket, by giving --session.

Examples using the default private abstract unix socket

 $ ./lws-minimal-dbus-server
[2018/10/03 07:08:02:6448] USER: LWS minimal dbus server
[2018/10/03 07:08:02:6693] NOTICE: Creating Vhost 'default' port 0, 1 protocols, IPv6 off
...

You can communicate with the dbus server over its private abstract socket using, eg

$ gdbus introspect --address unix:abstract=org.libwebsockets.test --dest org.libwebsockets.test --object-path /org/libwebsockets/test
node /org/example/TestObject {
  interface org.freedesktop.DBus.Introspectable {
    methods:
      Introspect(out s data);
    signals:
    properties:
  };
  interface org.freedesktop.DBus.Properties {
    methods:
      Get(in  s interface,
...
$ gdbus call --address unix:abstract=org.libwebsockets.test --dest org.libwebsockets.test --object-path /org/libwebsockets/test --method org.libwebsockets.test.Echo HELLO
('HELLO',)

Examples using the DBUS session bus

 $ ./lws-minimal-dbus-server --session
[2018/10/03 07:08:02:6448] USER: LWS minimal dbus server
[2018/10/03 07:08:02:6693] NOTICE: Creating Vhost 'default' port 0, 1 protocols, IPv6 off
...

You can communicate with the dbus server over the session bus using, eg

$ gdbus introspect --session --dest org.libwebsockets.test --object-path /org/libwebsockets/test
node /org/example/TestObject {
  interface org.freedesktop.DBus.Introspectable {
    methods:
      Introspect(out s data);
    signals:
    properties:
  };
  interface org.freedesktop.DBus.Properties {
    methods:
      Get(in  s interface,
...
$ gdbus call --session --dest org.libwebsockets.test --object-path /org/libwebsockets/test --method org.libwebsockets.test.Echo HELLO
('HELLO',)