diff --git a/lib/xmpp-client/client.js b/lib/xmpp-client/client.js index 73f7f32..a9d4513 100644 --- a/lib/xmpp-client/client.js +++ b/lib/xmpp-client/client.js @@ -160,9 +160,9 @@ Client.prototype.message = function(to, message) { Client.prototype.askForRoster = function(callback) { var jabber = this; this.iq(new xmpp.Element('query', {xmlns: 'jabber:iq:roster'}), function(iq) { - iq.getChild('query', 'jabber:iq:roster').children.forEach(function(child) { + iq.getChild('query', 'jabber:iq:roster').getChildren('item').forEach(function(child) { jabber.roster[child.attrs.jid] = { - name: child.attrs.name, + name: child.attrs.jid, subscription: child.attrs.subscription}; }); if(callback != null) { @@ -260,10 +260,12 @@ Room.prototype.presence = function() { Room.prototype.message = function(message) { this.client.xmpp.send(new xmpp.Element('message', { - to: this.to, - type: 'groupchat'}) + to: this.room, + type: 'groupchat', + id: this.client._iq++ + }) +// .c('nick', {xmlns: 'http://jabber.org/protocol/nick'}).t(this.client.jid.username).up() .c('body').t(message).up() -// .c('nick', {xmlns: 'http://jabber.org/protocol/nick'}).t(this.client.jid.username) .tree() ); }; \ No newline at end of file diff --git a/test/test.js b/test/test.js index c0f564c..c416550 100644 --- a/test/test.js +++ b/test/test.js @@ -48,14 +48,20 @@ exports.testClient = function(test) { */ exports.testRoom = function(test) { - test.expect(1); + //test.expect(1); var ROOM = 'mushroom@conference.' + conf.b.jid.split('@')[1]; var MESSAGE = "Hello everybody"; var b = new Client(conf.b, function() { sys.debug('b is connected'.red); sys.debug(('enter in ' + ROOM).green); + //console.log(sys.inspect(this, true, null)); var b_room = b.room(ROOM, function(status) { - var a = new Client(conf.a, function() { + this.addListener('message', function(from, msg, stanza) { + sys.debug(msg.yellow); + test.done(); + }); + this.message(MESSAGE); +/* var a = new Client(conf.a, function() { sys.debug('a is connected'.green); var a_room = a.room(ROOM, function(status) { sys.debug(status); @@ -69,8 +75,7 @@ exports.testRoom = function(test) { }); b_room.message(MESSAGE); }); - }); - + });*/ }); }); };