1
0
Fork 0

event and callback for roster

master
Matthieu Lalonde 14 years ago committed by Mathieu Lecarme
parent d18443dbff
commit 2ad8122354

@ -70,7 +70,9 @@ var Client = function(params, callback) {
jabber._debug("[Info] xmpp connection"); jabber._debug("[Info] xmpp connection");
jabber.presence(); jabber.presence();
jabber.emit('online'); jabber.emit('online');
jabber.askForRoster(); jabber.askForRoster(function(roster) {
jabber._debug("ROSTER : "[jabber.color] + JSON.stringify(roster));
});
if(callback != null) { if(callback != null) {
callback.call(jabber); callback.call(jabber);
} }
@ -121,11 +123,6 @@ var Client = function(params, callback) {
} }
query = stanza.getChild('query', 'jabber:iq:version'); query = stanza.getChild('query', 'jabber:iq:version');
if(query != null) { if(query != null) {
/* <query xmlns='jabber:iq:version'>
<name>Exodus</name>
<version>0.7.0.4</version>
<os>Windows-XP 5.01.2600</os>
</query>*/
jabber.resultIq(stanza, new xmpp.Element('query', {xmlns:'jabber:iq:version'}) jabber.resultIq(stanza, new xmpp.Element('query', {xmlns:'jabber:iq:version'})
.c('name').t('node-xmpp-client').up() .c('name').t('node-xmpp-client').up()
.c('version').t('0.0.1').up() .c('version').t('0.0.1').up()
@ -153,7 +150,7 @@ Client.prototype.message = function(to, message) {
t(message)); t(message));
}; };
Client.prototype.askForRoster = function() { 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(new xmpp.Element('query', {xmlns: 'jabber:iq:roster'}), function(iq) {
iq.getChild('query', 'jabber:iq:roster').children.forEach(function(child) { iq.getChild('query', 'jabber:iq:roster').children.forEach(function(child) {
@ -161,8 +158,10 @@ Client.prototype.askForRoster = function() {
name: child.attrs.name, name: child.attrs.name,
subscription: child.attrs.subscription}; subscription: child.attrs.subscription};
}); });
jabber._debug("ROSTER : "[jabber.color] + JSON.stringify(jabber.roster)); if(callback != null) {
jabber.emit('roster', iq); callback.call(jabber, jabber.roster);
}
jabber.emit('roster', jabber.roster);
}); });
}; };

Loading…
Cancel
Save