Start reading from the recv channel earlier.
authorChris Jones <christian.jones@sri.com>
Mon, 09 Sep 2013 04:17:06 +0100
changeset 137 c94a7ce0f4fb
parent 136 f35f853a52b6
child 138 065f54e291c7
Start reading from the recv channel earlier.
example/interact.go
--- a/example/interact.go	Mon Sep 09 04:16:16 2013 +0100
+++ b/example/interact.go	Mon Sep 09 04:17:06 2013 +0100
@@ -52,6 +52,13 @@
 	}
 	defer close(c.Send)
 
+	go func(ch <-chan xmpp.Stanza) {
+		for obj := range ch {
+			fmt.Printf("s: %v\n", obj)
+		}
+		fmt.Println("done reading")
+	}(c.Recv)
+
 	err = c.StartSession(&xmpp.Presence{})
 	if err != nil {
 		log.Fatalf("StartSession: %v", err)
@@ -63,13 +70,6 @@
 		fmt.Printf("%d: %v\n", i, entry)
 	}
 
-	go func(ch <-chan xmpp.Stanza) {
-		for obj := range ch {
-			fmt.Printf("s: %v\n", obj)
-		}
-		fmt.Println("done reading")
-	}(c.Recv)
-
 	p := make([]byte, 1024)
 	for {
 		nr, _ := os.Stdin.Read(p)