1
0
Fork 0

better roster handling, muc message

master
Matthieu Lalonde 14 years ago committed by Mathieu Lecarme
parent d7c1994ffb
commit 81d13189a1

@ -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()
);
};

@ -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);
});
});
});*/
});
});
};

Loading…
Cancel
Save