Listen for XMPP connection status changes, and print them out.
authorChris Jones <chris@cjones.org>
Sun, 29 Sep 2013 21:54:38 -0600
changeset 159 fd4089f717b2
parent 158 2d948fcbb5d7
child 160 ba2428230f71
Listen for XMPP connection status changes, and print them out.
example/interact.go
--- a/example/interact.go	Sun Sep 29 21:37:14 2013 -0600
+++ b/example/interact.go	Sun Sep 29 21:54:38 2013 -0600
@@ -41,8 +41,14 @@
 		os.Exit(2)
 	}
 
+	stat := make(chan xmpp.Status)
+	go func() {
+		for s := range stat {
+			log.Printf("connection status %d", s)
+		}
+	}()
 	tlsConf := tls.Config{InsecureSkipVerify: true}
-	c, err := xmpp.NewClient(&jid, *pw, tlsConf, nil, xmpp.Presence{}, nil)
+	c, err := xmpp.NewClient(&jid, *pw, tlsConf, nil, xmpp.Presence{}, stat)
 	if err != nil {
 		log.Fatalf("NewClient(%v): %v", jid, err)
 	}