1
0
Fork 0
master
Matthieu Lalonde 14 years ago committed by Mathieu Lecarme
parent 8ce3836be9
commit f01e68ad1d

@ -41,11 +41,15 @@ var BasicClient = function(params, callback) {
default: default:
jabber.emit('iq', stanza); jabber.emit('iq', stanza);
var q = stanza.getChild('query'); var q = stanza.getChild('query');
if(q == undefined) {
jabber.emit('iq:unknow', stanza);
} else {
if(q.attrs.xmlns != null && jabber._iqHandler[q.attrs.xmlns] != null) { if(q.attrs.xmlns != null && jabber._iqHandler[q.attrs.xmlns] != null) {
jabber._iqHandler[q.attrs.xmlns].call(jabber, stanza); jabber._iqHandler[q.attrs.xmlns].call(jabber, stanza);
} else { } else {
jabber.emit('iq:unknow', stanza); jabber.emit('iq:unknow', stanza);
} }
}
break; break;
} }
break; break;
@ -81,7 +85,7 @@ BasicClient.prototype.presence = function(type) {
}; };
BasicClient.prototype.iq = function(to, query, callback, error) { BasicClient.prototype.iq = function(to, query, callback, error) {
error |= function(stanza) { sys.error(stanza);}; error |= function(stanza) { sys.error((this.jid + " : " + stanza.toString()).red);};
var n = 'node' + this._iq++; var n = 'node' + this._iq++;
this._iqCallback[n] = [callback, error]; this._iqCallback[n] = [callback, error];
var attrs = { var attrs = {

@ -26,13 +26,18 @@ exports.testIq = function(test) {
}; };
exports.testPresence = function(test) { exports.testPresence = function(test) {
/*
[FIXME] this test don't manage Resource, if you have an opened jabber client, it may hurt this test
*/
test.expect(1); test.expect(1);
var prems = true;
var b = new BasicClient(conf.b, function() { var b = new BasicClient(conf.b, function() {
this.addListener('presence', function(presence) { this.addListener('presence', function(presence) {
//sys.debug(presence.attrs.from.split('/')[0].red); //sys.debug(presence.attrs.from.red);
if(presence.attrs.from.split('/')[0] == conf.a.jid) { if(presence.attrs.from.split('/')[0] == conf.a.jid && prems) {
test.ok(true, "B is present"); test.ok(true, "B is present");
test.done(); test.done();
prems = false;
} }
}); });
var a = new BasicClient(conf.a, function() { var a = new BasicClient(conf.a, function() {

Loading…
Cancel
Save