5 [DBus (name = "org.example.Test")]
6 interface Test : Object {
7 public abstract string[] test_property { owned get; set; }
9 public abstract int[] test_int (int[] i, out int[] j) throws DBus.Error;
10 public abstract string[] test_string (string[] s, out string[] t) throws DBus.Error;
14 var conn = DBus.Bus.get (DBus.BusType.SESSION);
17 var test = (Test) conn.get_object ("org.example.Test", "/org/example/test");
20 k = test.test_int ({ 42 }, out j);
21 assert (j.length == 1 && j[0] == 23);
22 assert (k.length == 1 && k[0] == 11);
25 u = test.test_string ({ "hello" }, out t);
26 assert (t.length == 1 && t[0] == "world");
27 assert (u.length == 1 && u[0] == "vala");
29 test.test_property = { "hello" };
30 t = test.test_property;
31 assert (t.length == 1 && t[0] == "hello");
36 [DBus (name = "org.example.Test")]
38 public string[] test_property { owned get; set; }
40 public int[] test_int (int[] i, out int[] j) {
41 assert (i.length == 1 && i[0] == 42);
46 public string[] test_string (string[] s, out string[] t) {
47 assert (s.length == 1 && s[0] == "hello");
55 void client_exit (Pid pid, int status) {
56 // client finished, terminate server
62 var conn = DBus.Bus.get (DBus.BusType.SESSION);
63 dynamic DBus.Object bus = conn.get_object ("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus");
65 // try to register service in session bus
66 uint request_name_result = bus.request_name ("org.example.Test", (uint) 0);
67 assert (request_name_result == DBus.RequestNameReply.PRIMARY_OWNER);
70 var server = new Test ();
71 conn.register_object ("/org/example/test", server);
73 // server ready, spawn client
75 Process.spawn_async (null, { "test", "/dbus/arrays/client" }, null, SpawnFlags.DO_NOT_REAP_CHILD, null, out client_pid);
76 ChildWatch.add (client_pid, client_exit);
78 main_loop = new MainLoop (null, false);