|
|
|
@ -9,6 +9,17 @@ function Pubsub(client, to) {
|
|
|
|
|
to = 'pubsub.' + this.client.jid.domain;
|
|
|
|
|
}
|
|
|
|
|
this.to = to;
|
|
|
|
|
this._eventCallback = {};
|
|
|
|
|
var pubsub = this;
|
|
|
|
|
this.client.addListener('pubsub:event', function(from, node, event_, stanza) {
|
|
|
|
|
if(from == pubsub.to) {
|
|
|
|
|
sys.debug('a pubsub event'.yellow);
|
|
|
|
|
var cb = pubsub._eventCallback[node];
|
|
|
|
|
if(cb != null) {
|
|
|
|
|
cb.call(pubsub, event_, stanza);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
sys.inherits(Pubsub, events.EventEmitter);
|
|
|
|
@ -153,7 +164,7 @@ Pubsub.prototype.suscribe = function(node, onMessage, onSuscribed) {
|
|
|
|
|
.tree(),
|
|
|
|
|
function(iq) {
|
|
|
|
|
sys.debug(('Suscribe to ' + node).yellow);
|
|
|
|
|
jabber._pubSubCallback[pubsub.to + '#' + node] = onMessage;
|
|
|
|
|
pubsub._eventCallback[node] = onMessage;
|
|
|
|
|
var s = iq.getChild('pubsub', 'http://jabber.org/protocol/pubsub').attrs;
|
|
|
|
|
onSuscribed.call(jabber, s.subscription, s.subid);
|
|
|
|
|
}
|
|
|
|
|