Wrox Programmer Forums
|
BOOK: Professional XMPP Programming with JavaScript and jQuery
This is the forum to discuss the Wrox book Professional XMPP Programming with JavaScript and jQuery by Jack Moffitt; ISBN: 978-0-470-54071-8
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional XMPP Programming with JavaScript and jQuery section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 24th, 2012, 04:49 AM
Registered User
 
Join Date: Apr 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Joomla Strophe problem

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("[email protected]", "826cc6f2", "12467", null);
		conn.sendIQ(
			$iq({to: Strophe.getDomainFromJid("[email protected]"),
				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 ...?
 
Old April 25th, 2012, 04:47 PM
Wrox Author
 
Join Date: Jan 2010
Posts: 178
Thanks: 0
Thanked 16 Times in 15 Posts
Default

Your mootools appears to be monkeypatching Function.prototype.bind in such a way that it is incompatible with the one Strophe uses.

I bet if you remove mootools it will work fine.
 
Old April 26th, 2012, 04:55 AM
Registered User
 
Join Date: Apr 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

VirtueMart is a free, open source shopping cart solution developed for Joomla, a content management system. It is coded in PHP format and can be fully integrated into any Joomla e-commerce website. Much like Joomla, VirtueMart can be modified and customized with no restrictions. In addition to shopping cart features, VirtueMart can be run as a catalog. It can handle numerous categories, products, customers, kommunikation and shipping modules. You can even sell downloadable goods such as MP3 files, software and videos. Learn how to install VirtueMart on your Joomla website.





Similar Threads
Thread Thread Starter Forum Replies Last Post
BOSH, Strophe, and Openfire iowadeifan BOOK: Professional XMPP Programming with JavaScript and jQuery 11 March 31st, 2014 03:08 PM
Strophe hangs after attaching nielsvh BOOK: Professional XMPP Programming with JavaScript and jQuery 1 February 5th, 2012 07:37 PM
Joomla 1.6 nand BOOK: Joomla! 24-Hour Trainer 1 June 19th, 2011 01:24 PM
Strophe Connection Error jpeterson7755 BOOK: Professional XMPP Programming with JavaScript and jQuery 1 February 28th, 2011 01:48 AM
Using sha1 passwords in Strophe.js semper BOOK: Professional XMPP Programming with JavaScript and jQuery 1 June 28th, 2010 02:15 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.