166 } |
166 } |
167 |
167 |
168 // Register a callback to handle the next XMPP stanza (iq, message, or |
168 // Register a callback to handle the next XMPP stanza (iq, message, or |
169 // presence) with a given id. The provided function will not be called |
169 // presence) with a given id. The provided function will not be called |
170 // more than once. If it returns false, the stanza will not be made |
170 // more than once. If it returns false, the stanza will not be made |
171 // available on the normal Client.In channel. The stanza handler |
171 // available on the normal Client.Recv channel. The callback must not |
172 // must not read from that channel, as deliveries on it cannot proceed |
172 // read from that channel, as deliveries on it cannot proceed until |
173 // until the handler returns true or false. |
173 // the handler returns true or false. |
174 func (cl *Client) HandleStanza(id string, f func(Stanza) bool) { |
174 func (cl *Client) SetCallback(id string, f func(Stanza) bool) { |
175 h := &stanzaHandler{id: id, f: f} |
175 h := &callback{id: id, f: f} |
176 cl.handlers <- h |
176 cl.handlers <- h |
177 } |
177 } |
178 |
178 |
179 // Send a request to bind a resource. RFC 3920, section 7. |
179 // Send a request to bind a resource. RFC 3920, section 7. |
180 func (cl *Client) bind(bindAdv *bindIq) { |
180 func (cl *Client) bind(bindAdv *bindIq) { |