6 [DBus (name = "org.example.Test")]
7 interface Test : Object {
8 public abstract async void test_void () throws IOError;
9 public abstract async int test_int (int i, out int j) throws IOError;
10 public abstract async string test_string (string s, out string t) throws IOError;
16 Test test = yield Bus.get_proxy (BusType.SESSION, "org.example.Test", "/org/example/test");
18 yield test.test_void ();
21 k = yield test.test_int (42, out j);
26 u = yield test.test_string ("hello", out t);
27 assert (t == "world");
37 main_loop = new MainLoop (null, false);
43 [DBus (name = "org.example.Test")]
45 public async void test_void () {
46 Idle.add (test_void.callback);
50 public async int test_int (int i, out int j) {
52 Idle.add (test_int.callback);
58 public async string test_string (string s, out string t) {
59 assert (s == "hello");
60 Idle.add (test_string.callback);
69 void client_exit (Pid pid, int status) {
70 // client finished, terminate server
76 var conn = Bus.get_sync (BusType.SESSION);
77 conn.register_object ("/org/example/test", new Test ());
79 // try to register service in session bus
80 var request_result = conn.call_sync ("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", "RequestName",
81 new Variant ("(su)", "org.example.Test", 0x4), null, 0, -1);
82 assert ((uint) request_result.get_child_value (0) == 1);
84 // server ready, spawn client
86 Process.spawn_async (null, { "test", "/dbus/async/client" }, null, SpawnFlags.DO_NOT_REAP_CHILD, null, out client_pid);
87 ChildWatch.add (client_pid, client_exit);
89 main_loop = new MainLoop ();