1
0
Fork 0

battle with presences

master
Matthieu Lalonde 15 years ago committed by Mathieu Lecarme
parent 3ccb77d7c8
commit 5da3ec3a17

@ -25,6 +25,7 @@ var Client = function(_jid, password, host) {
this.rooms = {};
this._iq = 0;
this._iqCallback = {};
this.presences = {};
this.roster = {};
this.xmpp = new xmpp.Client({
host: this.host,
@ -57,7 +58,7 @@ var Client = function(_jid, password, host) {
if(fromm[1] == 'conference.' + this.jid.domain) {
jabber.rooms[fromm[0]].emit('presence', stanza);
} else {
jabber.emit('presence', stanza);
jabber.emit('presence', stanza.attrs.from, stanza);
}
}
if(stanza.name == 'message') {
@ -85,6 +86,9 @@ var Client = function(_jid, password, host) {
this.addListener('iqResult', function(id, stanza){
jabber._iqCallback[id].call(jabber, stanza);
});
this.addListener('presence', function(from, stanza) {
jabber.presences[from] = stanza.attrs.type;
});
};
sys.inherits(Client, events.EventEmitter);

@ -38,6 +38,8 @@ exports.testClient = function(test) {
var a = new Client(conf.a.jid, conf.a.password);
a.addListener('online', function() {
sys.debug('a is connected'.green);
sys.debug('a presences : ' + JSON.stringify(a.presences).green);
// test.equals('available', a.presences['' + b.jid]);
test.ok(true);
a.message(conf.b.jid, MESSAGE);
});

Loading…
Cancel
Save