[gnome-chess/chess-telepathy-networking-support-664946-communicate: 8/10] Modify gdbus-client test to asynchronously fetch objects



commit 17c6502039a6a9ed931681f920cdd52ab29c4773
Author: Chandni Verma <chandniverma2112 gmail com>
Date:   Fri Dec 28 08:28:25 2012 +0530

    Modify gdbus-client test to asynchronously fetch objects

 tests/test-demo-gdbus-client.vala |   46 ++++++++++++++++++++-----------------
 1 files changed, 25 insertions(+), 21 deletions(-)
---
diff --git a/tests/test-demo-gdbus-client.vala b/tests/test-demo-gdbus-client.vala
index 354806f..318ea34 100644
--- a/tests/test-demo-gdbus-client.vala
+++ b/tests/test-demo-gdbus-client.vala
@@ -16,28 +16,32 @@ void main () {
     /* Important: keep demo variable out of try/catch scope not lose signals! */
     Demo demo = null;
 
-    try {
-        demo = Bus.get_proxy_sync (BusType.SESSION, "org.example.Demo",
-                                                    "/org/example/demo");
+    Bus.get_proxy<Demo> (BusType.SESSION, "org.example.Demo", "/org/example/demo", 0, null,
+        (obj, res)=>{
+            try {
+                demo = Bus.get_proxy.end (res);
+
+                /* Connecting to signal pong! */
+                demo.pong.connect((c, m) => {
+                    stdout.printf ("Got pong %d for msg '%s'\n", c, m);
+                    loop.quit ();
+                });
+
+                int pong = demo.ping ("Hello from Vala");
+                stdout.printf ("%d\n", pong);
+
+                pong = demo.ping_with_sender ("Hello from Vala with sender");
+                stdout.printf ("%d\n", pong);
+
+                pong = demo.ping_with_signal ("Hello from Vala with signal");
+                stdout.printf ("%d\n", pong);
+            }
+            catch (IOError e) {
+                stderr.printf ("%s\n", e.message);
+            }
+        }
+      );
 
-        /* Connecting to signal pong! */
-        demo.pong.connect((c, m) => {
-            stdout.printf ("Got pong %d for msg '%s'\n", c, m);
-            loop.quit ();
-        });
-
-        int pong = demo.ping ("Hello from Vala");
-        stdout.printf ("%d\n", pong);
-
-        pong = demo.ping_with_sender ("Hello from Vala with sender");
-        stdout.printf ("%d\n", pong);
-
-        pong = demo.ping_with_signal ("Hello from Vala with signal");
-        stdout.printf ("%d\n", pong);
-
-    } catch (IOError e) {
-        stderr.printf ("%s\n", e.message);
-    }
     loop.run();
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]