147 { |
147 { |
148 this.debug("SND: "+data); |
148 this.debug("SND: "+data); |
149 this.socket.send(data.toString()); |
149 this.socket.send(data.toString()); |
150 }, |
150 }, |
151 |
151 |
|
152 sendIQ: function (iq, on_result, on_error) |
|
153 { |
|
154 if(!iq.attr.id) |
|
155 iq.attr.id = this.getUniqueId(); |
|
156 this.addHandler(function (reply) { |
|
157 if(reply.attr.type == "result") |
|
158 return on_result(reply); |
|
159 elseif(on_error) |
|
160 return on_error(reply); |
|
161 return false; |
|
162 |
|
163 }, null, "iq", null, iq.attr.id); |
|
164 this.send(iq); |
|
165 }, |
152 |
166 |
153 addHandler: function (handler, ns, name, type, id, from, options) |
167 addHandler: function (handler, ns, name, type, id, from, options) |
154 { |
168 { |
155 return this.handlers.push({ |
169 return this.handlers.push({ |
156 callback: handler, |
170 callback: handler, |