1. #1
    Ext User
    Join Date
    Feb 2009
    Posts
    3
    Vote Rating
    0
    freygrob is on a distinguished road

      0  

    Question 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 :
    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);
        });
        
    });
    and php backend (poll.php) :
    Code:
    <?php
        $time = date(DATE_ATOM, time());
        
        echo json_encode(array(
            "type" => "event",
            "name" => "message",
            "data" => $time
        ));
    ?>
    => ok for polling from Ext.Direct.

    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 :
    Code:
    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
      }
    or

    Code:
    while(1) {
       echo json_encode(...);
       sleep(1); // something to do on the server that takes long time...
    }

  2. #2
    Ext User
    Join Date
    Jul 2007
    Location
    Florida
    Posts
    9,996
    Vote Rating
    5
    mjlecomte will become famous soon enough mjlecomte will become famous soon enough

      0  

    Default


    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).

  3. #3
    Ext User deanna's Avatar
    Join Date
    Aug 2007
    Location
    Alabama
    Posts
    306
    Vote Rating
    0
    deanna is on a distinguished road

      0  

    Default


    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.

  4. #4
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,909
    Vote Rating
    626
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    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!

  5. #5
    Ext User
    Join Date
    Jul 2007
    Location
    Florida
    Posts
    9,996
    Vote Rating
    5
    mjlecomte will become famous soon enough mjlecomte will become famous soon enough

      0  

    Default


    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.

  6. #6
    Ext User
    Join Date
    Feb 2009
    Posts
    3
    Vote Rating
    0
    freygrob is on a distinguished road

      0  

    Default


    @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.

  7. #7
    Sencha User
    Join Date
    Sep 2007
    Location
    Tulsa, Oklahoma
    Posts
    178
    Vote Rating
    1
    ckr is on a distinguished road

      0  

    Default


    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

  8. #8
    jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    Frederick MD, NYC, DC
    Posts
    16,360
    Vote Rating
    81
    jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all

      0  

    Default


    Quote Originally Posted by mjlecomte View Post
    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.
    I remember these exchanges, but have not had time to test