diff --git a/lib/xmpp-client/basic-client.js b/lib/xmpp-client/basic-client.js index 0c46398..839edb9 100644 --- a/lib/xmpp-client/basic-client.js +++ b/lib/xmpp-client/basic-client.js @@ -41,10 +41,14 @@ var BasicClient = function(params, callback) { default: jabber.emit('iq', stanza); var q = stanza.getChild('query'); - if(q.attrs.xmlns != null && jabber._iqHandler[q.attrs.xmlns] != null) { - jabber._iqHandler[q.attrs.xmlns].call(jabber, stanza); - } else { + if(q == undefined) { jabber.emit('iq:unknow', stanza); + } else { + if(q.attrs.xmlns != null && jabber._iqHandler[q.attrs.xmlns] != null) { + jabber._iqHandler[q.attrs.xmlns].call(jabber, stanza); + } else { + jabber.emit('iq:unknow', stanza); + } } break; } @@ -81,7 +85,7 @@ BasicClient.prototype.presence = function(type) { }; 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++; this._iqCallback[n] = [callback, error]; var attrs = { diff --git a/test/test-basic.js b/test/test-basic.js index f3c5c60..2734154 100644 --- a/test/test-basic.js +++ b/test/test-basic.js @@ -26,13 +26,18 @@ exports.testIq = 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); + var prems = true; var b = new BasicClient(conf.b, function() { this.addListener('presence', function(presence) { - //sys.debug(presence.attrs.from.split('/')[0].red); - if(presence.attrs.from.split('/')[0] == conf.a.jid) { + //sys.debug(presence.attrs.from.red); + if(presence.attrs.from.split('/')[0] == conf.a.jid && prems) { test.ok(true, "B is present"); test.done(); + prems = false; } }); var a = new BasicClient(conf.a, function() {