Hello,
I'm trying to develop a custom Joomla 2.5 component that will use session attachment method described in Chapter 12.
I'm using PHP to make an initial connection with my OpenFire XMPP server.
When I tested it with a simple PHP page, I received jid, sid and rid without any problems. I passed them to the JavaScript and used them to attach to the xmpp session. Everything was OK, attaching was successful.
When I tried the same procedure in Joomla 2.5, everything was OK from the PHP side, I received sid, rid and jid, I passed them to the Javascript correctly, but the problem arised when I was trying to call Strophe's Connection.attach method. Parameters are passed OK, I checked with the debugger.
Code:
<script>
$(document).ready(function () {
var conn = new Strophe.Connection("http://10.1.206.52/ofv/");
conn.attach("user@domain", "826cc6f2", "12467", null);
conn.sendIQ(
$iq({to: Strophe.getDomainFromJid("user@domain"),
type: "get"})
.c('query', {xmlns:
'http://jabber.org/protocol/disco#info'}),
function () {
$('#log').append("<div>Response received " +
"from server!</div>");
});
});
</script>
I received a Javascript error:
Code:
Uncaught TypeError: Cannot read property 'id' of undefined
Strophe.Connection._onRequestStateChange strophe.js:2631
(anonymous function) mootools-core.js:87
(anonymous function) mootools-core.js:87
Strophe.Connection._processRequest strophe.js:2539
Strophe.Connection._onIdle strophe.js:3572
(anonymous function) mootools-core.js:87
I also tried to make a simple connection in Joomla with the xmpp server directly from the Javascript with Strophe, without session attachment. I received the same error which leads me to the conclusion that the problem probably is the combination Joomla - Strophe. From the error description, I think that mootools
js is causing the error in Strophe, but I have no idea how this can be fixed.
This is the part of the code that causes the error (according to the debugger):
Code:
Strophe:
onRequestStateChange: function (func, reqt)
{
Strophe.debug("request id " + reqt.id +
Uncaught TypeError: Cannot read property 'id' of undefined
Uncaught TypeError: Cannot read property 'id' of undefined
"." + reqt.sends + " state changed to " +
reqt.xhr.readyState);
if (reqt.abort) {
reqt.abort = false;
return;
}
MooTools Core:
...
84 },periodical:function(c,b,a){return setInterval(this.pass((a==null?[]:a),b),c);}});delete Function.prototype.bind;Function.implement({create:function(b){var a=this;
85 b=b||{};return function(d){var c=b.arguments;c=(c!=null)?Array.from(c):Array.slice(arguments,(b.event)?1:0);if(b.event){c=[d||window.event].extend(c);}var e=function(){return a.apply(b.bind||null,c);
86 };if(b.delay){return setTimeout(e,b.delay);}if(b.periodical){return setInterval(e,b.periodical);}if(b.attempt){return Function.attempt(e);}return e();};
87 },bind:function(c,b){var a=this;if(b!=null){b=Array.from(b);}return function(){return a.apply(c,b||arguments);};},bindWithEvent:function(c,b){var a=this;
88 if(b!=null){b=Array.from(b);}return function(d){return a.apply(c,(b==null)?arguments:[d].concat(b));};},run:function(a,b){return this.apply(b,Array.from(a));
89 }});if(Object.create==Function.prototype.create){Object.create=null;}var $try=Function.attempt;(function(){var a=Object.prototype.hasOwnProperty;Object.extend({subset:function(d,g){var f={};
90 for(var e=0,b=g.length;e<b;e++){var c=g[e];if(c in d){f[c]=d[c];}}return f;},map:function(b,e,f){var d={};for(var c in b){if(a.call(b,c)){d[c]=e.call(f,b[c],c,b);
...
Does anyone have an idea how this can be fixed? The idea of the project is to use Joomla CMS as a frontend. Should I use another Javascript client side library or ...?