xmpp.go
changeset 20 e119444a1119
parent 17 d269d9c0fc8e
child 22 d6b7b4cbf50d
equal deleted inserted replaced
19:e923f28d65aa 20:e119444a1119
     4 
     4 
     5 // This package implements a simple XMPP client according to RFCs 3920
     5 // This package implements a simple XMPP client according to RFCs 3920
     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 // TODO Figure out why the library doesn't exit when the server closes
     9 // BUG(cjyar) Figure out why the library doesn't exit when the server
    10 // its stream to us.
    10 // closes its stream to us.
    11 
    11 
    12 import (
    12 import (
    13 	"bytes"
    13 	"bytes"
    14 	"fmt"
    14 	"fmt"
    15 	"io"
    15 	"io"
    31 
    31 
    32 	// DNS SRV names
    32 	// DNS SRV names
    33 	serverSrv = "xmpp-server"
    33 	serverSrv = "xmpp-server"
    34 	clientSrv = "xmpp-client"
    34 	clientSrv = "xmpp-client"
    35 
    35 
    36 	// TODO Make this a parameter to NewClient, not a
    36 	// BUG(cjyar) Make this a parameter to NewClient, not a
    37 	// constant. We should have both a log level and a
    37 	// constant. We should have both a log level and a
    38 	// syslog.Writer, so the app can control how much time we
    38 	// syslog.Writer, so the app can control how much time we
    39 	// spend generating log messages, as well as where they go.
    39 	// spend generating log messages, as well as where they go.
    40 	debug = true
    40 	debug = true
    41 )
    41 )
    56 	nextId int64
    56 	nextId int64
    57 	handlers chan *stanzaHandler
    57 	handlers chan *stanzaHandler
    58 	// Incoming XMPP stanzas from the server will be published on
    58 	// Incoming XMPP stanzas from the server will be published on
    59 	// this channel. Information which is only used by this
    59 	// this channel. Information which is only used by this
    60 	// library to set up the XMPP stream will not appear here.
    60 	// library to set up the XMPP stream will not appear here.
    61 	// TODO Make these channels of type Stanza.
    61 	// BUG(cjyar) Make these channels of type Stanza.
    62 	In <-chan interface{}
    62 	In <-chan interface{}
    63 	// Outgoing XMPP stanzas to the server should be sent to this
    63 	// Outgoing XMPP stanzas to the server should be sent to this
    64 	// channel.
    64 	// channel.
    65 	Out chan<- interface{}
    65 	Out chan<- interface{}
    66 	xmlOut chan<- interface{}
    66 	xmlOut chan<- interface{}
    67 	// TODO Remove this. Make a Stanza parser method available for
    67 	// BUG(cjyar) Remove this. Make a Stanza parser method
    68 	// use by interact.go and similar applications.
    68 	// available for use by interact.go and similar applications.
    69 	TextOut chan<- *string
    69 	TextOut chan<- *string
    70 }
    70 }
    71 var _ io.Closer = &Client{}
    71 var _ io.Closer = &Client{}
    72 
    72 
    73 // Connect to the appropriate server and authenticate as the given JID
    73 // Connect to the appropriate server and authenticate as the given JID