|
|
|
@ -11,6 +11,7 @@ var Client = function(params, callback) {
|
|
|
|
|
this.jid = new xmpp.JID(params.jid);
|
|
|
|
|
this.host = (params.host == null) ? this.jid.domain : params.host;
|
|
|
|
|
this.rooms = {};
|
|
|
|
|
this._isReady = false;
|
|
|
|
|
this._iq = 0;
|
|
|
|
|
this._iqHandler = {};
|
|
|
|
|
this._iqCallback = {};
|
|
|
|
@ -86,7 +87,7 @@ var Client = function(params, callback) {
|
|
|
|
|
});
|
|
|
|
|
this.addListener('groupchat', function(from, msg, stanza) {
|
|
|
|
|
fromName = from.split('/')[0];
|
|
|
|
|
jabber.rooms[fromName].emit('message', msg, stanza);
|
|
|
|
|
jabber.rooms[fromName].emit('message', from, msg, stanza);
|
|
|
|
|
});
|
|
|
|
|
this.addListener('iqResult', function(id, stanza){
|
|
|
|
|
jabber._iqCallback[id].call(jabber, stanza);
|
|
|
|
@ -166,7 +167,10 @@ Client.prototype.askForRoster = function(callback) {
|
|
|
|
|
subscription: child.attrs.subscription};
|
|
|
|
|
});
|
|
|
|
|
if(callback != null) {
|
|
|
|
|
callback.call(jabber, jabber.roster);
|
|
|
|
|
if(! jabber._isReady) { //[FIXME] will not work if askForRoster is called again
|
|
|
|
|
jabber._isReady = true;
|
|
|
|
|
callback.call(jabber, jabber.roster);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
jabber.emit('roster', jabber.roster);
|
|
|
|
|
});
|
|
|
|
@ -221,6 +225,7 @@ Client.prototype.disconnect = function() {
|
|
|
|
|
|
|
|
|
|
var Room = function(client, name, callback) {
|
|
|
|
|
events.EventEmitter.call(this);
|
|
|
|
|
this._isReady = false;
|
|
|
|
|
this.client = client;
|
|
|
|
|
this.room = name;
|
|
|
|
|
this.to = this.room + '/' + this.client.jid.user;
|
|
|
|
@ -236,7 +241,10 @@ var Room = function(client, name, callback) {
|
|
|
|
|
room.role = item.attrs.role;
|
|
|
|
|
}
|
|
|
|
|
var status = x.getChild('status');
|
|
|
|
|
callback.call(room, (status != null) ? status.attrs.code : '200');
|
|
|
|
|
if(! room._isReady) {
|
|
|
|
|
room._isReady = true;
|
|
|
|
|
callback.call(room, (status != null) ? status.attrs.code : '200');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|