Added an interactive test and made Client implement io.Closer.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/interact.go Sat Dec 24 11:18:52 2011 -0700
@@ -0,0 +1,31 @@
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+import (
+ "cjyar/xmpp"
+ "flag"
+ "log"
+ "os"
+ )
+
+// 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")
+ flag.Parse()
+ if jid.Domain == "" || *pw == "" {
+ flag.Usage()
+ os.Exit(2)
+ }
+
+ c, err := xmpp.NewClient(&jid, *pw)
+ if err != nil {
+ log.Fatalf("NewClient(%v): %v", jid, err)
+ }
+ defer c.Close()
+}
--- a/xmpp.go Sat Dec 24 11:05:54 2011 -0700
+++ b/xmpp.go Sat Dec 24 11:18:52 2011 -0700
@@ -8,6 +8,7 @@
import (
"fmt"
+ "io"
"net"
"os"
)
@@ -23,6 +24,7 @@
//Out chan<- *Stanza
tcp *net.TCPConn
}
+var _ io.Closer = &Client{}
// Connect to the appropriate server and authenticate as the given JID
// with the given password.
@@ -58,3 +60,7 @@
cl.tcp = c
return &cl, nil
}
+
+func (c *Client) Close() os.Error {
+ return c.tcp.Close()
+}