76 handlers chan *stanzaHandler |
76 handlers chan *stanzaHandler |
77 inputControl chan int |
77 inputControl chan int |
78 // Incoming XMPP stanzas from the remote will be published on |
78 // Incoming XMPP stanzas from the remote will be published on |
79 // this channel. Information which is used by this library to |
79 // this channel. Information which is used by this library to |
80 // set up the XMPP stream will not appear here. |
80 // set up the XMPP stream will not appear here. |
81 In <-chan Stanza |
81 Recv <-chan Stanza |
82 // Outgoing XMPP stanzas to the server should be sent to this |
82 // Outgoing XMPP stanzas to the server should be sent to this |
83 // channel. |
83 // channel. |
84 Out chan<- Stanza |
84 Send chan<- Stanza |
85 xmlOut chan<- interface{} |
85 sendXml chan<- interface{} |
86 // The client's roster is also known as the buddy list. It's |
86 // The client's roster is also known as the buddy list. It's |
87 // the set of contacts which are known to this JID, or which |
87 // the set of contacts which are known to this JID, or which |
88 // this JID is known to. |
88 // this JID is known to. |
89 Roster Roster |
89 Roster Roster |
90 // Features advertised by the remote. This will be updated |
90 // Features advertised by the remote. This will be updated |
156 |
156 |
157 // Start the reader and writer that convert to and from XML. |
157 // Start the reader and writer that convert to and from XML. |
158 recvXml := make(chan interface{}) |
158 recvXml := make(chan interface{}) |
159 go readXml(recvReader, recvXml, extStanza) |
159 go readXml(recvReader, recvXml, extStanza) |
160 sendXml := make(chan interface{}) |
160 sendXml := make(chan interface{}) |
161 cl.xmlOut = sendXml |
161 cl.sendXml = sendXml |
162 go writeXml(sendWriter, sendXml) |
162 go writeXml(sendWriter, sendXml) |
163 |
163 |
164 // Start the reader and writer that convert between XML and |
164 // Start the reader and writer that convert between XML and |
165 // XMPP stanzas. |
165 // XMPP stanzas. |
166 recvRawXmpp := make(chan Stanza) |
166 recvRawXmpp := make(chan Stanza) |
169 go writeStream(sendXml, sendRawXmpp, cl.inputControl) |
169 go writeStream(sendXml, sendRawXmpp, cl.inputControl) |
170 |
170 |
171 // Start the manager for the filters that can modify what the |
171 // Start the manager for the filters that can modify what the |
172 // app sees. |
172 // app sees. |
173 recvFiltXmpp := make(chan Stanza) |
173 recvFiltXmpp := make(chan Stanza) |
174 cl.In = recvFiltXmpp |
174 cl.Recv = recvFiltXmpp |
175 go filterMgr(cl.recvFilterAdd, recvRawXmpp, recvFiltXmpp) |
175 go filterMgr(cl.recvFilterAdd, recvRawXmpp, recvFiltXmpp) |
176 sendFiltXmpp := make(chan Stanza) |
176 sendFiltXmpp := make(chan Stanza) |
177 cl.Out = sendFiltXmpp |
177 cl.Send = sendFiltXmpp |
178 go filterMgr(cl.sendFilterAdd, sendFiltXmpp, sendFiltXmpp) |
178 go filterMgr(cl.sendFilterAdd, sendFiltXmpp, sendFiltXmpp) |
179 |
179 |
180 // Initial handshake. |
180 // Initial handshake. |
181 hsOut := &stream{To: jid.Domain, Version: XMPPVersion} |
181 hsOut := &stream{To: jid.Domain, Version: XMPPVersion} |
182 cl.xmlOut <- hsOut |
182 cl.sendXml <- hsOut |
183 |
183 |
184 return cl, nil |
184 return cl, nil |
185 } |
185 } |
186 |
186 |
187 func tee(r io.Reader, w io.Writer, prefix string) { |
187 func tee(r io.Reader, w io.Writer, prefix string) { |