# HG changeset patch # User Chris Jones # Date 1326052898 25200 # Node ID d693ecc11f297b3a53c4d48e9bb2272c00d5182e # Parent e8ad85bb6608b3f45c5d9d70b5e8cac69ee66db1 Restore this example program to its normal operation. diff -r e8ad85bb6608 -r d693ecc11f29 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") }