|
|
@ -74,9 +74,7 @@ var Client = function(_jid, password, host) {
|
|
|
|
this.xmpp.addListener('online', function() {
|
|
|
|
this.xmpp.addListener('online', function() {
|
|
|
|
jabber._debug("[Info] xmpp connection");
|
|
|
|
jabber._debug("[Info] xmpp connection");
|
|
|
|
jabber.presence();
|
|
|
|
jabber.presence();
|
|
|
|
jabber.iq(new xmpp.Element('query', {xmlns: 'jabber:iq:roster'}), function(iq) {
|
|
|
|
jabber.askForRoster();
|
|
|
|
jabber._debug("MY ROSTER" + iq);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
jabber.emit('online');
|
|
|
|
jabber.emit('online');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
this.addListener('groupchat', function(from, stanza) {
|
|
|
|
this.addListener('groupchat', function(from, stanza) {
|
|
|
@ -108,6 +106,19 @@ Client.prototype.message = function(to, message) {
|
|
|
|
t(message));
|
|
|
|
t(message));
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Client.prototype.askForRoster = function() {
|
|
|
|
|
|
|
|
var jabber = this;
|
|
|
|
|
|
|
|
this.iq(new xmpp.Element('query', {xmlns: 'jabber:iq:roster'}), function(iq) {
|
|
|
|
|
|
|
|
iq.getChild('query', 'jabber:iq:roster').children.forEach(function(child) {
|
|
|
|
|
|
|
|
jabber.roster[child.attrs.jid] = {
|
|
|
|
|
|
|
|
name: child.attrs.name,
|
|
|
|
|
|
|
|
subscription: child.attrs.subscription};
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
jabber._debug("ROSTER : " + JSON.stringify(jabber.roster));
|
|
|
|
|
|
|
|
jabber.emit('roster', iq);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Client.prototype.iq = function(iq, callback) {
|
|
|
|
Client.prototype.iq = function(iq, callback) {
|
|
|
|
var n = this._iq++;
|
|
|
|
var n = this._iq++;
|
|
|
|
this._iqCallback[n] = callback;
|
|
|
|
this._iqCallback[n] = callback;
|
|
|
|