From 44740b78402c0e1963c42cb6863671610bdd3ee0 Mon Sep 17 00:00:00 2001 From: Matthieu Lalonde Date: Sun, 28 Nov 2010 22:05:20 +0100 Subject: [PATCH] parsed version --- lib/xmpp-client/client.js | 11 ++++++++++- test/test-iq.js | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/xmpp-client/client.js b/lib/xmpp-client/client.js index 3a7b877..db894e2 100644 --- a/lib/xmpp-client/client.js +++ b/lib/xmpp-client/client.js @@ -62,10 +62,19 @@ Client.prototype.getRoster = function(callback) { }); }; +/* +http://xmpp.org/extensions/xep-0092.html +*/ Client.prototype.getVersion = function(jid, callback, error) { var jabber = this; 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); }; diff --git a/test/test-iq.js b/test/test-iq.js index 7a1eaea..bcd3610 100644 --- a/test/test-iq.js +++ b/test/test-iq.js @@ -11,8 +11,8 @@ exports.testIq = function(test) { var b = new Client(conf.b, function() { //sys.debug(this.jid.toString().blue); a.getVersion(b.jid, function(version) { - sys.debug(version.toString().yellow); - test.ok(true, 'version'); + sys.debug(JSON.stringify(version).yellow); + test.equals('node-xmpp-client',version.name, 'same client'); test.done(); }, function(iq) {