equal
deleted
inserted
replaced
1 // Copyright 2011 The Go Authors. All rights reserved. |
1 // Copyright 2011 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style |
2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. |
3 // license that can be found in the LICENSE file. |
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/. The |
|
7 // implementation is structured as a stack of layers, with TCP at the |
|
8 // bottom and the application at the top. The application receives and |
|
9 // sends structures representing XMPP stanzas. Additional stanza |
|
10 // parsers can be inserted into the stack of layers as extensions. |
7 package xmpp |
11 package xmpp |
8 |
12 |
9 import ( |
13 import ( |
10 "bytes" |
14 "bytes" |
11 "crypto/tls" |
15 "crypto/tls" |
36 clientSrv = "xmpp-client" |
40 clientSrv = "xmpp-client" |
37 ) |
41 ) |
38 |
42 |
39 // Extensions can add stanza filters and/or new XML element types. |
43 // Extensions can add stanza filters and/or new XML element types. |
40 type Extension struct { |
44 type Extension struct { |
|
45 // Maps from an XML namespace to a function which constructs a |
|
46 // structure to hold the contents of stanzas in that |
|
47 // namespace. |
41 StanzaHandlers map[string]func(*xml.Name) interface{} |
48 StanzaHandlers map[string]func(*xml.Name) interface{} |
42 Start func(*Client) |
49 Start func(*Client) |
43 } |
50 } |
44 |
51 |
45 // Allows the user to override the TLS configuration. |
52 // Allows the user to override the TLS configuration. |
59 socketSync sync.WaitGroup |
66 socketSync sync.WaitGroup |
60 saslExpected string |
67 saslExpected string |
61 authDone bool |
68 authDone bool |
62 handlers chan *stanzaHandler |
69 handlers chan *stanzaHandler |
63 inputControl chan int |
70 inputControl chan int |
64 // Incoming XMPP stanzas from the server will be published on |
71 // Incoming XMPP stanzas from the remote will be published on |
65 // this channel. Information which is only used by this |
72 // this channel. Information which is used by this library to |
66 // library to set up the XMPP stream will not appear here. |
73 // set up the XMPP stream will not appear here. |
67 In <-chan Stanza |
74 In <-chan Stanza |
68 // Outgoing XMPP stanzas to the server should be sent to this |
75 // Outgoing XMPP stanzas to the server should be sent to this |
69 // channel. |
76 // channel. |
70 Out chan<- Stanza |
77 Out chan<- Stanza |
71 xmlOut chan<- interface{} |
78 xmlOut chan<- interface{} |