stream.go
changeset 81 a74e7fc4ecee
parent 78 a5848c75d270
child 82 7ce2432dd66a
equal deleted inserted replaced
80:b0aa1bf902ee 81:a74e7fc4ecee
    29 // Callback to handle a stanza with a particular id.
    29 // Callback to handle a stanza with a particular id.
    30 type stanzaHandler struct {
    30 type stanzaHandler struct {
    31 	id string
    31 	id string
    32 	// Return true means pass this to the application
    32 	// Return true means pass this to the application
    33 	f func(Stanza) bool
    33 	f func(Stanza) bool
       
    34 }
       
    35 
       
    36 // BUG(cjyar): There's no way to specify xml:lang for the top-level
       
    37 // <stream:stream> element as the default language for this client.
       
    38 
       
    39 // Generate the "open stream" element which tells the remote we want
       
    40 // to speak XMPP. This is actually done 3 times, since we renegotiate
       
    41 // our transport layer with TLS and then with SASL.
       
    42 func openStream(jid *JID) *stream {
       
    43 	return &stream{To: jid.Domain, Version: Version}
    34 }
    44 }
    35 
    45 
    36 // BUG(cjyar) Review all these *Client receiver methods. They should
    46 // BUG(cjyar) Review all these *Client receiver methods. They should
    37 // probably either all be receivers, or none.
    47 // probably either all be receivers, or none.
    38 
    48 
   418 	}
   428 	}
   419 	cl.Features = nil
   429 	cl.Features = nil
   420 
   430 
   421 	// Now re-send the initial handshake message to start the new
   431 	// Now re-send the initial handshake message to start the new
   422 	// session.
   432 	// session.
   423 	hsOut := &stream{To: cl.Jid.Domain, Version: Version}
   433 		hsOut := openStream()
   424 	cl.xmlOut <- hsOut
   434 	cl.xmlOut <- hsOut
   425 }
   435 }
   426 
   436 
   427 // Synchronize with handleTls(). Called from readTransport() when
   437 // Synchronize with handleTls(). Called from readTransport() when
   428 // cl.socket is nil.
   438 // cl.socket is nil.
   481 	case "success":
   491 	case "success":
   482 		if Log != nil && Loglevel >= syslog.LOG_INFO {
   492 		if Log != nil && Loglevel >= syslog.LOG_INFO {
   483 			Log.Println("Sasl authentication succeeded")
   493 			Log.Println("Sasl authentication succeeded")
   484 		}
   494 		}
   485 		cl.Features = nil
   495 		cl.Features = nil
   486 		ss := &stream{To: cl.Jid.Domain, Version: Version}
   496 		cl.xmlOut <- openStream(cl.Jid)
   487 		cl.xmlOut <- ss
       
   488 	}
   497 	}
   489 }
   498 }
   490 
   499 
   491 func (cl *Client) saslDigest1(srvMap map[string]string) {
   500 func (cl *Client) saslDigest1(srvMap map[string]string) {
   492 	// Make sure it supports qop=auth
   501 	// Make sure it supports qop=auth