equal
deleted
inserted
replaced
21 |
21 |
22 // Various XML namespaces. |
22 // Various XML namespaces. |
23 nsStreams = "urn:ietf:params:xml:ns:xmpp-streams" |
23 nsStreams = "urn:ietf:params:xml:ns:xmpp-streams" |
24 nsStream = "http://etherx.jabber.org/streams" |
24 nsStream = "http://etherx.jabber.org/streams" |
25 nsTLS = "urn:ietf:params:xml:ns:xmpp-tls" |
25 nsTLS = "urn:ietf:params:xml:ns:xmpp-tls" |
|
26 nsSASL = "urn:ietf:params:xml:ns:xmpp-sasl" |
26 |
27 |
27 // DNS SRV names |
28 // DNS SRV names |
28 serverSrv = "xmpp-server" |
29 serverSrv = "xmpp-server" |
29 clientSrv = "xmpp-client" |
30 clientSrv = "xmpp-client" |
30 |
31 |
32 ) |
33 ) |
33 |
34 |
34 // The client in a client-server XMPP connection. |
35 // The client in a client-server XMPP connection. |
35 type Client struct { |
36 type Client struct { |
36 Jid JID |
37 Jid JID |
|
38 password string |
37 socket net.Conn |
39 socket net.Conn |
38 socketSync sync.WaitGroup |
40 socketSync sync.WaitGroup |
|
41 saslExpected string |
39 In <-chan interface{} |
42 In <-chan interface{} |
40 Out chan<- interface{} |
43 Out chan<- interface{} |
41 xmlOut chan<- interface{} |
44 xmlOut chan<- interface{} |
42 TextOut chan<- *string |
45 TextOut chan<- *string |
43 } |
46 } |
72 if tcp == nil { |
75 if tcp == nil { |
73 return nil, err |
76 return nil, err |
74 } |
77 } |
75 |
78 |
76 cl := new(Client) |
79 cl := new(Client) |
|
80 cl.password = password |
77 cl.Jid = *jid |
81 cl.Jid = *jid |
78 cl.socket = tcp |
82 cl.socket = tcp |
79 |
83 |
80 // Start the transport handler, initially unencrypted. |
84 // Start the transport handler, initially unencrypted. |
81 tlsr, tlsw := cl.startTransport() |
85 tlsr, tlsw := cl.startTransport() |
134 return ch |
138 return ch |
135 } |
139 } |
136 |
140 |
137 func (cl *Client) startStreamReader(xmlIn <-chan interface{}, srvOut chan<- interface{}) <-chan interface{} { |
141 func (cl *Client) startStreamReader(xmlIn <-chan interface{}, srvOut chan<- interface{}) <-chan interface{} { |
138 ch := make(chan interface{}) |
142 ch := make(chan interface{}) |
139 go cl.readStream(xmlIn, srvOut, ch) |
143 go cl.readStream(xmlIn, ch) |
140 return ch |
144 return ch |
141 } |
145 } |
142 |
146 |
143 func startStreamWriter(xmlOut chan<- interface{}) chan<- interface{} { |
147 func startStreamWriter(xmlOut chan<- interface{}) chan<- interface{} { |
144 ch := make(chan interface{}) |
148 ch := make(chan interface{}) |