README.md
1Boost D-Bus
2===========
3
4This is a simple D-Bus binding powered by Boost.Asio.
5As far as possible, I try to follow Asio's idioms.
6
7Code Sample
8-----------
9
10```c++
11#include <iostream>
12
13#include <boost/asio.hpp>
14#include <dbus.hpp>
15
16using namespace std;
17using namespace boost::asio;
18using boost::system::error_code;
19
20struct logger
21{
22 void operator()(error_code ec, message m)
23 {
24 cout << m << endl;
25 }
26};
27
28void main()
29{
30 io_service io;
31 dbus::proxy avahi(io,
32 dbus::endpoint(
33 "org.freedesktop.Avahi", // proxied object process
34 "/", // proxied object path
35 "org.freedesktop.Avahi.Server")); // interface
36
37 dbus::message browser_spec(-1, -1,
38 "_http._tcp", "local", unsigned(0));
39
40 dbus::message response =
41 avahi.call("ServiceBrowserNew", browser_spec);
42
43 dbus::proxy browser(io,
44 dbus::endpoint(
45 "org.freedesktop.Avahi",
46 response.get(0),
47 "org.freedesktop.Avahi.ServiceBrowser"));
48
49 browser.async_receive("ItemNew", logger());
50
51 io.run();
52}
53
54
55```
56