equal
deleted
inserted
replaced
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 "bytes" |
10 "bytes" |
|
11 "crypto/tls" |
11 "encoding/xml" |
12 "encoding/xml" |
12 "errors" |
13 "errors" |
13 "fmt" |
14 "fmt" |
14 "io" |
15 "io" |
15 "net" |
16 "net" |
56 // Extensions can add stanza filters and/or new XML element types. |
57 // Extensions can add stanza filters and/or new XML element types. |
57 type Extension struct { |
58 type Extension struct { |
58 StanzaHandlers map[string]func(*xml.Name) interface{} |
59 StanzaHandlers map[string]func(*xml.Name) interface{} |
59 Start func(*Client) |
60 Start func(*Client) |
60 } |
61 } |
|
62 |
|
63 // Allows the user to override the TLS configuration. |
|
64 var TlsConfig tls.Config |
61 |
65 |
62 // The client in a client-server XMPP connection. |
66 // The client in a client-server XMPP connection. |
63 type Client struct { |
67 type Client struct { |
64 // This client's unique ID. It's unique within the context of |
68 // This client's unique ID. It's unique within the context of |
65 // this process, so if multiple Client objects exist, each |
69 // this process, so if multiple Client objects exist, each |
267 iq := &Iq{To: cl.Jid.Domain, Id: id, Type: "set", Nested: []interface{}{Generic{XMLName: xml.Name{Space: NsSession, Local: "session"}}}} |
271 iq := &Iq{To: cl.Jid.Domain, Id: id, Type: "set", Nested: []interface{}{Generic{XMLName: xml.Name{Space: NsSession, Local: "session"}}}} |
268 ch := make(chan error) |
272 ch := make(chan error) |
269 f := func(st Stanza) bool { |
273 f := func(st Stanza) bool { |
270 iq, ok := st.(*Iq) |
274 iq, ok := st.(*Iq) |
271 if !ok { |
275 if !ok { |
272 Warn.Logf("iq reply not iq; can't start session") |
276 Warn.Log("iq reply not iq; can't start session") |
273 ch <- errors.New("bad session start reply") |
277 ch <- errors.New("bad session start reply") |
274 return false |
278 return false |
275 } |
279 } |
276 if iq.Type == "error" { |
280 if iq.Type == "error" { |
277 Warn.Logf("Can't start session: %v", iq) |
281 Warn.Logf("Can't start session: %v", iq) |