1
0
Fork 0
master
Matthieu Lalonde 14 years ago committed by Mathieu Lecarme
parent 44740b7840
commit 1d41e04749

@ -65,7 +65,7 @@ Client.prototype.getRoster = function(callback) {
/*
http://xmpp.org/extensions/xep-0092.html
*/
Client.prototype.getVersion = function(jid, callback, error) {
Client.prototype.getVersion = function(jid, success, error) {
var jabber = this;
this.iq(jid, new xmpp.Element('query', {xmlns: 'jabber:iq:version'}), function(iq) {
var v = iq.getChild('query', 'jabber:iq:version');
@ -74,10 +74,24 @@ Client.prototype.getVersion = function(jid, callback, error) {
version: v.getChildText('version'),
os: v.getChildText('os')
};
callback.call(jabber, version);
success.call(jabber, version);
}, error);
};
/*
http://xmpp.org/extensions/xep-0012.html
*/
Client.prototype.getLast = function(jid, success, error) {
var jabber = this;
this.iq(jid, new xmpp.Element('query', {xmlns: 'jabber:iq:last'}),
function(iq) {
success.call(jabber, parseInt(iq.getChild('query', 'jabber:iq:last').attrs.seconds, 10));
},
error
);
};
Client.prototype.disconnect = function() {
this.xmpp.send(new xmpp.Element('presence', {type: 'unavailable'})
.c('status').t('Logged out')

@ -4,7 +4,7 @@ var sys = require('sys'),
Client = require('../lib/xmpp-client').Client,
conf = require('./conf').conf;
exports.testIq = function(test) {
exports.testVersion = function(test) {
test.expect(1);
var a = new Client(conf.a, function() {
//sys.debug(this.jid.toString().blue);
@ -21,4 +21,18 @@ exports.testIq = function(test) {
});
});
});
};
exports.testLast = function(test) {
test.expect(1);
var a = new Client(conf.a, function() {
//sys.debug(this.jid.toString().blue);
var b = new Client(conf.b, function() {
a.getLast(a.jid, function(version) {
sys.debug(version);
test.ok(version > 0, 'last');
test.done();
});
});
});
};
Loading…
Cancel
Save