-
17 Apr 2009 1:31 PM #1
ExtJS 3.0: Ext.Direct with PHP: Polling:ok and Pushing ?
ExtJS 3.0: Ext.Direct with PHP: Polling:ok and Pushing ?
Hi From Paris, France,
First, here's a sample of Ext.Direct.PollingProvider use with PHP (from original sample for .NET 3.5 written by shibub)
direct.js :
and php backend (poll.php) :Code:Ext.onReady(function() { var out = new Ext.form.DisplayField({ cls: 'x-form-text', id: 'out' }); var panel = new Ext.Panel({ title: 'Remote Call Log', width: 600, height: 300, layout: 'fit', fitToFrame: true, autoScroll: true, items: [out] }); panel.render(Ext.getBody()); Ext.Direct.addProvider({ type: 'polling', url: 'poll.php' }); Ext.Direct.on('message', function(e) { out.append(String.format('<p>Successfully polled at: {0}</p>', e.data)); out.el.scrollTo('t', 100000, true); }); });
=> ok for polling from Ext.Direct.Code:<?php $time = date(DATE_ATOM, time()); echo json_encode(array( "type" => "event", "name" => "message", "data" => $time )); ?>
But in Ext 3.0 Roadmap, I saw a "Comet support" line.
So, now, how can I "push" from server to client ?
Imagine if php backend was endless and, instead of polling each 3 seconds, pushing its data to client ?
Excuse my english !
I would like my php backend push data to ExtJS Client as this comet sample push data in a <iframe>: http://www.zeitoun.net/articles/comet_and_php/start
and do something like this in php backend :
orCode:while(1) { echo '<script type="text/javascript">'; echo 'comet.printServerTime('.time().');'; echo '</script>'; flush(); // used to send the echoed data to the client sleep(1); // a little break to unload the server CPU }
Code:while(1) { echo json_encode(...); sleep(1); // something to do on the server that takes long time... }
-
17 Apr 2009 2:11 PM #2
Do you realize there's already php samples included in the SDK? I did not detect any examples of pushing from the server though, so I'm confused about the alleged comet capability myself (I didn't go to the conference so I missed any conversation about this).
MJ
API Search || Ext 3: docs-demo-upgrade guide || User Extension Repository
Frequently Asked Questions: FAQs
Tutorial: Grid (php/mysql/json) , Application Design and Structure || Extensions: MetaGrid, MessageWindow
-
17 Apr 2009 2:28 PM #3
I don't think you would want to do much comet with php. PHP would tie up connections on your http server and cause bad overall performance. My impression of comet is you need something like a java serverlet or some other type of server that can hold open lots of connections.
My read on Ext.direct so far seems to be it is a way to easily import and use remote api's.
-
17 Apr 2009 2:32 PM #4
We will be implementing a LongPollingProvider (Comet) at some point. Stay tuned...
Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
-
17 Apr 2009 2:35 PM #5
Oh, by the way, I mentioned this to some folks and it kind of died. Perhaps some of y'all will study it and post any insights / findings. Open up the SDK direct example that polls the server with php (maybe this is a php issue as you say?). Anyway, leave it run for 3+ hours and watch the memory AND CPU usage of the browser. I found that the CPU usage really throttled my processor after a time.
MJ
API Search || Ext 3: docs-demo-upgrade guide || User Extension Repository
Frequently Asked Questions: FAQs
Tutorial: Grid (php/mysql/json) , Application Design and Structure || Extensions: MetaGrid, MessageWindow
-
17 Apr 2009 2:52 PM #6
@mjlecomte : I'm sorry I already use direct sample from SDK... to poll... but there is nothing about push...
@evant : Yes ! of course I stay tuned ! ExtJS is really a GOOD JOB !
Thank you ExtJS Team for all your works.
-
5 May 2009 5:01 AM #7
You might look here
This is not with Ext.Direct, but it does long polling which is what is typically used in a comet push. It is a very simplistic example. More would need to be added for timeouts etc.Thanks!
Chuck
-
5 May 2009 7:16 AM #8Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- Frederick MD, NYC, DC
- Posts
- 16,170
- Vote Rating
- 31

Jay Garcia @ModusJesus || Modus Create co-founder
Ext JS in Action author
Sencha Touch in Action author
Get in touch for Ext JS & Sencha Touch Touch Training
We are also working on Video-based Sencha Touch training: Check it out here.


Reply With Quote

