xmpp.go
changeset 4 a8fbec71a194
parent 2 4dabfef08c8c
child 5 faef59c8db05
equal deleted inserted replaced
3:6121aa2f21b1 4:a8fbec71a194
     6 // and 3921, plus the various XEPs at http://xmpp.org/protocols/.
     6 // and 3921, plus the various XEPs at http://xmpp.org/protocols/.
     7 package xmpp
     7 package xmpp
     8 
     8 
     9 import (
     9 import (
    10 	"fmt"
    10 	"fmt"
       
    11 	"io"
    11 	"net"
    12 	"net"
    12 	"os"
    13 	"os"
    13 )
    14 )
    14 
    15 
    15 const (
    16 const (
    21 type Client struct {
    22 type Client struct {
    22 	//In <-chan *Stanza
    23 	//In <-chan *Stanza
    23 	//Out chan<- *Stanza
    24 	//Out chan<- *Stanza
    24 	tcp *net.TCPConn
    25 	tcp *net.TCPConn
    25 }
    26 }
       
    27 var _ io.Closer = &Client{}
    26 
    28 
    27 // Connect to the appropriate server and authenticate as the given JID
    29 // Connect to the appropriate server and authenticate as the given JID
    28 // with the given password.
    30 // with the given password.
    29 func NewClient(jid *JID, password string) (*Client, os.Error) {
    31 func NewClient(jid *JID, password string) (*Client, os.Error) {
    30 	// Resolve the domain in the JID.
    32 	// Resolve the domain in the JID.
    56 
    58 
    57 	cl := Client{}
    59 	cl := Client{}
    58 	cl.tcp = c
    60 	cl.tcp = c
    59 	return &cl, nil
    61 	return &cl, nil
    60 }
    62 }
       
    63 
       
    64 func (c *Client) Close() os.Error {
       
    65 	return c.tcp.Close()
       
    66 }