--- a/example/interact.go Sun Feb 09 09:50:38 2014 -0700
+++ b/example/interact.go Sun Feb 09 09:52:28 2014 -0700
@@ -11,42 +11,34 @@
"strings"
)
-type StdLogger struct {
-}
-
-func (s *StdLogger) Log(v ...interface{}) {
- log.Println(v...)
-}
-
-func (s *StdLogger) Logf(fmt string, v ...interface{}) {
- log.Printf(fmt, v...)
-}
-
func init() {
- logger := &StdLogger{}
- // xmpp.Debug = logger
- xmpp.Info = logger
- xmpp.Warn = logger
+ // xmpp.Debug = true
}
// Demonstrate the API, and allow the user to interact with an XMPP
// server via the terminal.
func main() {
- var jid xmpp.JID
- flag.Var(&jid, "jid", "JID to log in as")
- var pw *string = flag.String("pw", "", "password")
+ jidStr := flag.String("jid", "", "JID to log in as")
+ pw := flag.String("pw", "", "password")
flag.Parse()
- if jid.Domain == "" || *pw == "" {
+ jid := xmpp.JID(*jidStr)
+ if jid.Domain() == "" || *pw == "" {
flag.Usage()
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)
}
- defer close(c.Send)
+ defer c.Close()
go func(ch <-chan xmpp.Stanza) {
for obj := range ch {