1
0
Fork 0
master
Matthieu Lalonde 14 years ago committed by Mathieu Lecarme
parent dc0263dc72
commit c610c7345e

@ -160,7 +160,7 @@ Client.prototype.message = function(to, message) {
Client.prototype.askForRoster = function(callback) { Client.prototype.askForRoster = function(callback) {
var jabber = this; var jabber = this;
this.iq(new xmpp.Element('query', {xmlns: 'jabber:iq:roster'}), function(iq) { this.iq(null, new xmpp.Element('query', {xmlns: 'jabber:iq:roster'}), function(iq) {
iq.getChild('query', 'jabber:iq:roster').getChildren('item').forEach(function(child) { iq.getChild('query', 'jabber:iq:roster').getChildren('item').forEach(function(child) {
jabber.roster[child.attrs.jid] = { jabber.roster[child.attrs.jid] = {
name: child.attrs.jid, name: child.attrs.jid,
@ -176,10 +176,24 @@ Client.prototype.askForRoster = function(callback) {
}); });
}; };
Client.prototype.iq = function(iq, callback) { Client.prototype.iq = function(to, query, callback) {
var n = this._iq++; var n = this._iq++;
this._iqCallback[n] = callback; this._iqCallback[n] = callback;
this.xmpp.send(new xmpp.Element('iq', {type:"get", id: n}).cnode(iq).tree()); var attrs = {
type:"get",
id: n
};
if(to != null) {
attrs.to = to;
};
this.xmpp.send(new xmpp.Element('iq', attrs).cnode(query).tree());
};
Client.prototype.iqSet = function(query) {
this.xmpp.send(new xmpp.Element('iq', {
type:"set",
id: this._iq++
}).cnode(query).tree());
}; };
Client.prototype.resultIq = function(iqGet, result) { Client.prototype.resultIq = function(iqGet, result) {

Loading…
Cancel
Save