xmpp/xmpp.go
changeset 130 da6f37ae3ffe
parent 129 cccf2b2fe34d
child 131 f9ccfaf672ed
equal deleted inserted replaced
129:cccf2b2fe34d 130:da6f37ae3ffe
    90 	// connection process. It should not be updated once
    90 	// connection process. It should not be updated once
    91 	// StartSession() returns.
    91 	// StartSession() returns.
    92 	Features                     *Features
    92 	Features                     *Features
    93 	sendFilterAdd, recvFilterAdd chan Filter
    93 	sendFilterAdd, recvFilterAdd chan Filter
    94 	// Allows the user to override the TLS configuration.
    94 	// Allows the user to override the TLS configuration.
    95 	TlsConfig tls.Config
    95 	tlsConfig tls.Config
    96 }
    96 }
    97 
    97 
    98 // Connect to the appropriate server and authenticate as the given JID
    98 // Connect to the appropriate server and authenticate as the given JID
    99 // with the given password. This function will return as soon as a TCP
    99 // with the given password. This function will return as soon as a TCP
   100 // connection has been established, but before XMPP stream negotiation
   100 // connection has been established, but before XMPP stream negotiation
   101 // has completed. The negotiation will occur asynchronously, and any
   101 // has completed. The negotiation will occur asynchronously, and any
   102 // send operation to Client.Out will block until negotiation (resource
   102 // send operation to Client.Out will block until negotiation (resource
   103 // binding) is complete.
   103 // binding) is complete.
   104 func NewClient(jid *JID, password string, exts []Extension) (*Client, error) {
   104 func NewClient(jid *JID, password string, tlsconf tls.Config, exts []Extension) (*Client, error) {
   105 	// Include the mandatory extensions.
   105 	// Include the mandatory extensions.
   106 	roster := newRosterExt()
   106 	roster := newRosterExt()
   107 	exts = append(exts, roster.Extension)
   107 	exts = append(exts, roster.Extension)
   108 	exts = append(exts, bindExt)
   108 	exts = append(exts, bindExt)
   109 
   109 
   138 	cl.password = password
   138 	cl.password = password
   139 	cl.Jid = *jid
   139 	cl.Jid = *jid
   140 	cl.socket = tcp
   140 	cl.socket = tcp
   141 	cl.handlers = make(chan *stanzaHandler, 100)
   141 	cl.handlers = make(chan *stanzaHandler, 100)
   142 	cl.inputControl = make(chan int)
   142 	cl.inputControl = make(chan int)
       
   143 	cl.tlsConfig = tlsconf
   143 
   144 
   144 	extStanza := make(map[xml.Name]reflect.Type)
   145 	extStanza := make(map[xml.Name]reflect.Type)
   145 	for _, ext := range exts {
   146 	for _, ext := range exts {
   146 		for k, v := range ext.StanzaHandlers {
   147 		for k, v := range ext.StanzaHandlers {
   147 			if _, ok := extStanza[k]; !ok {
   148 			if _, ok := extStanza[k]; !ok {