# HG changeset patch # User Matthew Wild # Date 1268937286 0 # Node ID 2651c3a7e621bfa04d6453feafc3a3d1b8c33404 # Parent ae502df979078f33c3434aad1d4d32a08a6e64e1 Add support for handling incoming messages to the MUC library diff -r ae502df97907 -r 2651c3a7e621 js/xmpp_muc.js --- a/js/xmpp_muc.js Thu Mar 18 18:33:27 2010 +0000 +++ b/js/xmpp_muc.js Thu Mar 18 18:34:46 2010 +0000 @@ -12,6 +12,7 @@ /* Initialize stanza handlers */ conn.addHandler(recontext(this, this.handle_join), null, "presence", null, null, null); conn.addHandler(recontext(this, this.handle_error), null, "presence", "error", null, null); + conn.addHandler(recontext(this, this.handle_message), null, "message", "groupchat", null, null); /* Return newly-created object */ return this; @@ -96,5 +97,20 @@ } } return true; + }, + + handle_message: function (stanza) + { + if(!this.callbacks.message) + return true; + + if(stanza.getAttribute("type") == "groupchat" && Strophe.getBareJidFromJid(stanza.getAttribute("from")) == this.jid) + { + var body = stanza.getElementsByTagName("body"); + if(body.length > 0 && stanza.getElementsByTagName("delay").length == 0) + this.callbacks.message(stanza, this, Strophe.getResourceFromJid(stanza.getAttribute("from")), Strophe.getText(body[0])); + } + return true; } + };