Restore this example program to its normal operation. 20120108-close
authorChris Jones <chris@cjones.org>
Sun, 08 Jan 2012 13:01:38 -0700
branch20120108-close
changeset 68 d693ecc11f29
parent 67 e8ad85bb6608
child 69 a38173c1c8b2
child 70 bb629d22148a
Restore this example program to its normal operation.
examples/interact.go
--- a/examples/interact.go	Sun Jan 08 12:56:48 2012 -0700
+++ b/examples/interact.go	Sun Jan 08 13:01:38 2012 -0700
@@ -10,7 +10,6 @@
 	"fmt"
 	"log"
 	"os"
-	"time"
 )
 
 // Demonstrate the API, and allow the user to interact with an XMPP
@@ -48,9 +47,20 @@
 		fmt.Println("done reading")
 	}(c.In)
 
-	time.Sleep(1e9 * 5)
-	fmt.Println("Shutting down.")
-	close(c.Out)
-	time.Sleep(1e9 * 5)
-	select {}
+	p := make([]byte, 1024)
+	for {
+		nr, _ := os.Stdin.Read(p)
+		if nr == 0 {
+			break
+		}
+		s := string(p)
+		stan, err := xmpp.ParseStanza(s)
+		if err == nil {
+			c.Out <- stan
+		} else {
+			fmt.Printf("Parse error: %v\n", err)
+			break
+		}
+	}
+	fmt.Println("done sending")
 }