1
0
Fork 0

parsed version

master
Matthieu Lalonde 14 years ago committed by Mathieu Lecarme
parent 4a0c4d0a8a
commit 44740b7840

@ -62,10 +62,19 @@ Client.prototype.getRoster = function(callback) {
}); });
}; };
/*
http://xmpp.org/extensions/xep-0092.html
*/
Client.prototype.getVersion = function(jid, callback, error) { Client.prototype.getVersion = function(jid, callback, error) {
var jabber = this; var jabber = this;
this.iq(jid, new xmpp.Element('query', {xmlns: 'jabber:iq:version'}), function(iq) { this.iq(jid, new xmpp.Element('query', {xmlns: 'jabber:iq:version'}), function(iq) {
callback.call(jabber, iq.getChild('query', 'jabber:iq:version') ); var v = iq.getChild('query', 'jabber:iq:version');
var version = {
name: v.getChildText('name'),
version: v.getChildText('version'),
os: v.getChildText('os')
};
callback.call(jabber, version);
}, error); }, error);
}; };

@ -11,8 +11,8 @@ exports.testIq = function(test) {
var b = new Client(conf.b, function() { var b = new Client(conf.b, function() {
//sys.debug(this.jid.toString().blue); //sys.debug(this.jid.toString().blue);
a.getVersion(b.jid, function(version) { a.getVersion(b.jid, function(version) {
sys.debug(version.toString().yellow); sys.debug(JSON.stringify(version).yellow);
test.ok(true, 'version'); test.equals('node-xmpp-client',version.name, 'same client');
test.done(); test.done();
}, },
function(iq) { function(iq) {

Loading…
Cancel
Save