Skip to content
Browse files

iq has q query

  • Loading branch information...
1 parent 71d19c3 commit 5b01738d25332612438119875d6c2bfba8ded73a @athoune committed Jan 29, 2011
Showing with 19 additions and 8 deletions.
  1. +2 −1 chat/chat_init.js
  2. +17 −7 js/poem.js
View
3 chat/chat_init.js
@@ -20,7 +20,8 @@ poem.XMPP.prototype.wannaTalk = function(to, callback, error) {
* @argument handler a closure that take two arguments, a boolean and a post action closure
*/
poem.XMPP.prototype.handleWannaTalk = function(handler) {
- this.handleIQ('wannatalk', function(iq, wannatalk) {
+ this.handleIQ("poem:iq:wannatalk", function(iq, query) {
+ var wannatalk = query.getElementsByTagName('wannatalk')[0];
poem.log(['wanna iq', iq, this]);
var type = wannatalk.getAttribute('type');
var from = iq.getAttribute('from');
View
24 js/poem.js
@@ -109,16 +109,26 @@ poem.XMPP = function(service, login, passwd, nickname) {
this.connection.rawInput = poem.rawInput;
this.connection.rawOutput = poem.rawOutput;
var __iq = function(iq) {
- poem.log(['iq', iq]);
- var children = iq.childNodes;
+ var query = iq.getElementsByTagName('query')[0];
+ poem.log(['iq', iq, query.getAttribute('xmlns')]);
+ var handlers = this._onIQ[query.getAttribute('xmlns')];
+ poem.log(this._onIQ);
+ if(handlers != null) {
+ poem.log(handlers);
+ for(var j=0; j < handlers.length; j++) {
+ handlers[j](iq, query);
+ }
+ }
+
+ /*var children = iq.childNodes;
for(var i=0; i < children.length; i++) {
var handlers = this._onIQ[children[i].nodeName];
if(handlers != null) {
for(var j=0; j < handlers.length; j++) {
handlers[j](iq, children[i]);
}
}
- }
+ }*/
return true;
};
var __presence = function(pres) {
@@ -317,11 +327,11 @@ poem.XMPP.prototype = {
handleNSIQ: function(namespace, node, handler) {
//[TODO]
},
- handleIQ: function(node, handler) {
- if(this._onIQ[node] == null) {
- this._onIQ[node] = [];
+ handleIQ: function(xmlns, handler) {
+ if(this._onIQ[xmlns] == null) {
+ this._onIQ[xmlns] = [];
}
- this._onIQ[node] = poem.append(this._onIQ[node], handler.bind(this));
+ this._onIQ[xmlns].push(handler.bind(this));
},
/**
* Alter presence stanza

0 comments on commit 5b01738

Please sign in to comment.
Something went wrong with that request. Please try again.