6 [DBus (name = "org.example.Test")]
7 interface Test : Object {
8 public abstract Variant test_string () throws IOError;
13 Test test = Bus.get_proxy_sync (BusType.SESSION, "org.example.Test", "/org/example/test");
15 Variant v = test.test_string ();
16 string[] s = (string[]) v;
17 assert (s.length == 1 && s[0] == "hello");
22 [DBus (name = "org.example.Test")]
24 public Variant test_string () {
25 string[] s = { "hello" };
32 void client_exit (Pid pid, int status) {
33 // client finished, terminate server
39 var conn = Bus.get_sync (BusType.SESSION);
40 conn.register_object ("/org/example/test", new Test ());
42 // try to register service in session bus
43 var request_result = conn.call_sync ("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", "RequestName",
44 new Variant ("(su)", "org.example.Test", 0x4), null, 0, -1);
45 assert ((uint) request_result.get_child_value (0) == 1);
47 // server ready, spawn client
49 Process.spawn_async (null, { "test", "/dbus/bug602003/client" }, null, SpawnFlags.DO_NOT_REAP_CHILD, null, out client_pid);
50 ChildWatch.add (client_pid, client_exit);
52 main_loop = new MainLoop ();