Topic: [0.2.1] Comet streaming plugin

Good news everyone,

I just uploaded the latest version of the comet streaming plugin - version 0.2.1. It contains 2 bugfixes for FireFox/Safari and Opera. The api and the included xajax rev haven't changed since version 0.2.0.

The demo still can be found here.

download

2 (edited by dabreaka 2008-07-19 9:51:39 PM)

Re: [0.2.1] Comet streaming plugin

nice, seems to have solved the problem that i was having smile
great job

Re: [0.2.1] Comet streaming plugin

Hi,

I found this plugin and I'm very impressed. Thanks.

Is there a way to include the browser konqueror (kde) to work with this plugin?

Best reagards Axel

Re: [0.2.1] Comet streaming plugin

Hi Axel,

the comet plugin currently supports 3 different JS ways of processing streams: XHR streaming for Firefox/Safari, Server Sent Events for Opera and ActiveX htmlfile for IE. Konqueror supports none of these methods and therefore I would have to create another workaround. I think that Konq. isn't worth it atm, since it's not that widely spreaded like the major browsers - I'm sorry. If Konqueror is going to support one of these methods in future I'll definitely add  it wink

Re: [0.2.1] Comet streaming plugin

Just spent around 15 hours straight trying to get this thing to work in my CMS within a class. Made some modifications (require -> require_once) in the source to avoid that messy instantiation between includes.

This:
$core = './xajax/xajax_core';
require_once $core . '/xajax.inc.php';
$xajax = new xajax();
require_once $core . '/xajaxPlugin.inc.php';
require_once $core . '/xajaxPluginManager.inc.php';
require_once './xajax/xajax_plugins/response/comet/comet.inc.php';

became this:
// XAjax+Comet plugin includes
$core = './xajax.comet/xajax/xajax_core';
require_once $core . '/xajax.inc.php';
require_once $core . '/xajaxPlugin.inc.php';
require_once $core . '/xajaxPluginManager.inc.php';
require_once $core . '/xajaxResponse.inc.php';
require_once './xajax.comet/xajax/xajax_plugins/response/comet/comet.inc.php';


This way I was able to do the require_once calls at the beginning of my php file and instantiate xajax within my class. The second thing where I lost a lot of time was tracing how to turn on comet flag for class members. For those of you trying to do the same thing here is the call:

$this->xajax->register(
  XAJAX_CALLABLE_OBJECT,
  &$this,
  array('member_method_of_this' => array('comet' => true)));

Another thing that messed me up was trying to use <input type="submit"> to activate the streaming. That was no good, seems to me like it starts a synchronous connection no matter what I do in the onClick handler. Once I changed to <input type="button"> all started to work just fine.

Since I cannot upload files here I have created a tarball of the modified source for you guys to check out: http://valdez.lir.dk/xajax.comet.tar.bz2 . Here is also a link to the phps showing how the code looked like when it started working: http://valdez.lir.dk/class.tx_seotools_pi1.phps . And you can see it live here: http://www.valdez.hr/en/seo-tools/ .

Re: [0.2.1] Comet streaming plugin

Wow!  Nice job and thank you for posting your results!

This feedback, despite it's direct reference to the comet plugin, helps us to know where to focus our (limited) time with regard to documentation.

Regarding the input type=submit... Yikes!  That sounds like a nasty little (illogical) issue in the browser... does this happen in all browsers or have you only tested in one?

Again Thank You!
// Joe

xajax Developer
Connect to me on LinkedIn:
http://www.linkedin.com/in/calledtoconstruct

Re: [0.2.1] Comet streaming plugin

I've tried only in FF and IE 6.0 running on wine. The behaviour looked like this: as soon as I would push the submit button, the browser would display the loading progress bar in the window status bar that is never seen on a working streaming request and would blatantly reload the entire page. Regarding that live sample link: http://www.valdez.hr/en/seo-tools/ , I forgot to make the access public. Now you can see the result without creating an account.

Thanks for a great library and plugin!

P.S. The comet php code is really well designed just needs some basic cleanup. This thing with includes being one of them.

Re: [0.2.1] Comet streaming plugin

Oh, I think the issue with the submit button is expected behavior.  When using a form onsubmit ... or a input type=submit... you must always return false at the end of your javascript event handler to keep the browser from performing the default action:

[code=html]
<input type="submit" onclick="xajax_doSomething(); return false;" />
[/code]

// Joe

xajax Developer
Connect to me on LinkedIn:
http://www.linkedin.com/in/calledtoconstruct

Re: [0.2.1] Comet streaming plugin

Exactly, you can either return false on your button or onsubmit in your form:

[code=html]
<form action="" onsubmit="xajax_function('foo');return false;">
[/code]

Using the onsubmit event you can also prevent the form from being submitted via ENTER in a text input field.

Re: [0.2.1] Comet streaming plugin

q_no wrote:

Using the onsubmit event you can also prevent the form from being submitted via ENTER in a text input field.

Didn't think of that one. Just checked it and it is correct. After the fix it works via ENTER, mouse click and focus+space combination.

Re: [0.2.1] Comet streaming plugin

I was able to break comet.php by adding this call at line 14:

$xajax->setFlag('debug', TRUE);

I already ran into this issue and was trying to debug it without success. The generated path to the debug js script is correct. Still it just keeps claiming xajax.debug is not defined...

Re: [0.2.1] Comet streaming plugin

The comet plugin doesn't support the debug mode, yet. The whole request/response cycles works completely different.

Re: [0.2.1] Comet streaming plugin

I see. I packaged the xajax+comet library for TYPO3 as an extension. Thanks for the great work!

Re: [0.2.1] Comet streaming plugin

The title of your plugin is a bit misleading...it doesn't contain beta4b, it's a SVN revision. You should also upgrade to the rc1 version. wink

Re: [0.2.1] Comet streaming plugin

I know this may not be the right place for this question but it pertains to this since I am using comet to create a chat-like environment.

I have users providing a username and password.  This part works fine.  But when the testComet() function is initiated it does not see the session variables that I set in the login script.  The session variables are $_SESSION['userid'] and so on.  However when I go to that fuction the variables do not show up. 

However, if you log in the second time they work just fine.  I'm sure it has to be something I am doing but I can't figure out what.

Re: [0.2.1] Comet streaming plugin

Hi dannic,

what function are you calling first? the comet function or the login? If you start the comet function first it doesn't know anything about vars set during its runtime. You have to use session_write_close() / session_start() inside your comet function in order to read/write new session vars.
You also have to take care with file based sessions, that a script using the session file locks that file for other processes until it calls session_write_close();

Re: [0.2.1] Comet streaming plugin

q_no wrote:

Hi dannic,

what function are you calling first? the comet function or the login? If you start the comet function first it doesn't know anything about vars set during its runtime. You have to use session_write_close() / session_start() inside your comet function in order to read/write new session vars.
You also have to take care with file based sessions, that a script using the session file locks that file for other processes until it calls session_write_close();

Thanks for the reply. 

I am calling the login function through the testNormal function.  It loads login as a module and executes the code.  Once done it places a button for the user to click on to start the testComet function.

I thought of the session_write_close() function after I posted and tried that.  At first glance it appeared to work but It hasn't actually worked.

Now, I haven't tried to actually start the session inside the testComet or testNormal functions.  I have it starting in the begining of the file with the rest of my includes for the database and smarty engine.

This does work just I have to log in twice before it recognizes the session vars so I think I have got something wrong or in the wrong order.

I'll try the session_start() inside each function to see if that helps.

Re: [0.2.1] Comet streaming plugin

Hi Developers.

I have another Problem with comet streaming plugin. I've made a script that shows me status information when I generate couple of PDF's, for instance.

I've tested it on a local Webserver (debian, php5, mysql5, 100Mbit/s Network-Connection) and it works pretty well.
Then I tested it an a 1&1 Virtaul-Server with suse linux, php5 and mysql5. On this Server the Comet-Script is very slow and the status-informations are appearing very late (only every 10th Line appr.). Could it be, that the Connection is too slow for transferring the response or is there a setting on the server, that i must define?

Thanks for your answers ( I hope you do wink )

Re: [0.2.1] Comet streaming plugin

Then I tested it an a 1&1 Virtaul-Server

The reason is simple...virtual servers suck, sorry wink

Re: [0.2.1] Comet streaming plugin

I tried upgrading 0.2.1 which contains SVN version as I understood to rc1 version of xajax but failed to get it working. My upgrade consisted of replacing the corresponding folders with new ones from rc1 package. Is this all that needs to be done? Will you do an official release with rc1 soon?

Re: [0.2.1] Comet streaming plugin

It should work with the RC1 vers... there weren't any major changes between the SVN rev from the comet plugin and the rc1 vers, but I'm going to release a new version soon after the 0.5 stable is out. Unfortunately I'm too busy atm to have a closer look at it....

Re: [0.2.1] Comet streaming plugin

Is there any solution to solve the "Maximum execution time of xx seconds exceeded" problem, not change setting in php.ini and .htaccess file.

23 (edited by freddrat 2008-09-25 10:55:34 AM)

Re: [0.2.1] Comet streaming plugin

Use set_time_limit(..) function to define the execution timeout for this script only! See code below for setting the time limit to nonfinite. Maybe you need to change TIMEOUT parameter in httpd.conf of Apache (if used) anyway to prevent HTTP-Timeout from web server (for further details click on the function name below!)

set_time_limit(0);

Re: [0.2.1] Comet streaming plugin

Freddrat, afaik set_time_limit() doesn't work in safe_mode. So it's not the perfect solution for everyone...

Re: [0.2.1] Comet streaming plugin

q_no wrote:

It should work with the RC1 vers...

Comet 0.2.1 does *not* work with xajax 0.5rc1.

Since q_no is busy w/ real work, and I'd rather move forward than backward (ie, not downgrade xajax), I'm going to see about tweaking comet to work w/ rc1.

Cheers (:

m.