|
|
|
@ -72,7 +72,7 @@ var Client = function(params, callback) {
|
|
|
|
|
jabber.emit('online');
|
|
|
|
|
jabber.askForRoster();
|
|
|
|
|
if(callback != null) {
|
|
|
|
|
callback.apply(jabber);
|
|
|
|
|
callback.call(jabber);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
this.addListener('groupchat', function(from, stanza) {
|
|
|
|
@ -193,10 +193,10 @@ Client.prototype.canonicalRoomName = function(room) {
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Client.prototype.room = function(name) {
|
|
|
|
|
Client.prototype.room = function(name, callback) {
|
|
|
|
|
var room = this.canonicalRoomName(name);
|
|
|
|
|
if(this.rooms[room] == null) {
|
|
|
|
|
this.rooms[room] = new Room(this, room);
|
|
|
|
|
this.rooms[room] = new Room(this, room, callback);
|
|
|
|
|
}
|
|
|
|
|
return this.rooms[room];
|
|
|
|
|
};
|
|
|
|
@ -214,10 +214,26 @@ Client.prototype.disconnect = function() {
|
|
|
|
|
sys.debug("disconnect from XMPP");
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var Room = function(client, room, callback) {
|
|
|
|
|
var Room = function(client, name, callback) {
|
|
|
|
|
events.EventEmitter.call(this);
|
|
|
|
|
this.client = client;
|
|
|
|
|
this.room = room;
|
|
|
|
|
this.room = name;
|
|
|
|
|
var room = this;
|
|
|
|
|
this.addListener('presence', function(from, stanza) {
|
|
|
|
|
var jfrom = new xmpp.JID(from);
|
|
|
|
|
if(name == jfrom.user + '@' + jfrom.domain) {
|
|
|
|
|
var x = stanza.getChild('x', 'http://jabber.org/protocol/muc#user');
|
|
|
|
|
if(x != null) {
|
|
|
|
|
var item = x.getChild('item');
|
|
|
|
|
if(item != null) {
|
|
|
|
|
room.affiliation = item.attrs.affiliation;
|
|
|
|
|
room.role = item.attrs.role;
|
|
|
|
|
}
|
|
|
|
|
var status = x.getChild('status');
|
|
|
|
|
callback.call(room, (status != null) ? status.attrs.code : '200');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
this.presence();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|