1. #1
    Ext User heidtmare's Avatar
    Join Date
    Mar 2007
    Location
    The Space Coast, FL
    Posts
    307
    Vote Rating
    0
    heidtmare is on a distinguished road

      0  

    Default Comet revisited

    Comet revisited


    I know it's been brought up before, but I feel that Ext could benefit from a Comet helper.
    This helper could create a hidden frame, make the initial request, watch for population changes, and put the content fragments into the desired final location.

    That would be a sweet little piece of Ext goodness.
    Anybody agree?
    Last edited by heidtmare; 19 Apr 2007 at 4:50 AM. Reason: Added Link
    I like it. Simple, easy to remember.
    ...but why is the rum gone?

  2. #2
    Ext JS Premium Member
    Join Date
    Mar 2007
    Posts
    122
    Vote Rating
    0
    kalebwalton is on a distinguished road

      0  

    Default


    I agree - it would be great to have some sort of push implementation supported by Ext.

  3. #3
    Sencha User
    Join Date
    Jun 2007
    Posts
    18
    Vote Rating
    0
    RutgerB is on a distinguished road

      0  

    Default


    It would indeed be great to have a Comet helper in extjs

  4. #4
    Sencha User
    Join Date
    Mar 2007
    Posts
    464
    Vote Rating
    1
    JorisA is on a distinguished road

      0  

    Default


    Maybe I dont really get the concept, but why not disable timeout and make an Ajax call. onSuccess handle the recieved data.

  5. #5
    Sencha User Ronaldo's Avatar
    Join Date
    Jul 2007
    Location
    Enschede, The Netherlands
    Posts
    290
    Vote Rating
    0
    Ronaldo is on a distinguished road

      0  

    Default


    Quote Originally Posted by JorisA View Post
    Maybe I dont really get the concept, but why not disable timeout and make an Ajax call. onSuccess handle the recieved data.
    The concept of comet is that every browser client should not poll for data, which is (theroretically?) less scalable, but the server should push (changed) data to clients viewing that data. Thus, you'll only need to transfer data when it's changed.

    Just my 2 cents

  6. #6
    Ext User cluettr's Avatar
    Join Date
    Apr 2007
    Location
    Boston, MA
    Posts
    336
    Vote Rating
    0
    cluettr is on a distinguished road

      0  

    Default


    I like the push concept and I was hopeful that a solid open-source and/or freely available framework would be available by now. While Dojo does have comet capabilities its poorly documented and I have yet to see a good example. I, like most, need examples to get off the ground.

  7. #7
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,503
    Vote Rating
    52
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    I use DWR's "reverse Ajax". It polls the server on a configurable timer. I have it polling every 30 seconds. Based on Java as a back end.

  8. #8
    Ext User
    Join Date
    May 2007
    Location
    Cyprus
    Posts
    3
    Vote Rating
    0
    k2pts is on a distinguished road

      0  

    Default


    The basic idea is the following:

    Code:
    http.onreadystatechange = function() {
        if (http.readyState == 3) {
          getData();
        } else if (http.readyState == 4) {
          // disconnected/completed
          if (http.status == 200) {
          // do something
          } else {
           // something wrong in http request
          }
        }
      }
    The above would work on Firefox provided that:

    * the connection remains open... it is also interesting/challenging how you can keep the connection open without consuming all resources on your server (e.g. release the thread serving the initial request and you use a master thread to push data to the subscribed connections)

    * you have some way to parse chunked response data, for example:

    Code:
     
      response = http.responseText.substring(http_last);
      if (response.match(/\}[\n\t ]+$/)) {
            response_chunks=response.split('\t');
            for (var j=0;j<response_chunks.length-1;j++) {
                 // do something
            }
     }
      http_last = http.responseText.length;
    IE (earlier versions for sure, don't know about IE7) needs some extra work as, IIRC, it won't allow you to access responseText while readyState==3. There is an alternative/workaround using iframes and simulating the aforementioned behaviour.

  9. #9
    Sencha Premium Member Troy Wolf's Avatar
    Join Date
    May 2007
    Location
    Kansas City
    Posts
    247
    Vote Rating
    2
    Troy Wolf is on a distinguished road

      0  

    Default


    I frequently revisit the idea of push communications in the web environment. For those that may not understand the concept...consider a web page that displays the score of a soccer game in progress. You visit the page, and every 30 seconds, the score numbers automatically update to reflect the current score. The page would probably use "AJAX" to do this. What if you want the page to update "immediately" when a goal is scored? How can you have the server push this new information to the clients? Today, most people solve this by having the client browser update at a higher frequency. That is, update every 5 seconds instead of 30.

    The downside is that now you have the browsers hitting the server every 5 seconds even though there may not be any new information. The browser has to keep asking "anything new?". It would seem that a way for the server to push new information when and only when it is available would be more efficient.

    However, this would require an open socket between the browser client and the server. In reality, the overhead of having every browser connection maintain an open socket is less scalable than having all those browsers making tiny requests every 5 seconds.

    So unless I am misunderstanding the technology (very possible), in a mass-public web app, push technology would not scale very well.

    Like many, when I'm in doubt about a best methodology, I look to Google---how do they do it? I figure if a method is good enough for Google, it's good enough for me.

  10. #10
    Sencha Developer
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    482
    Vote Rating
    1
    Wolfgang is on a distinguished road

      0  

    Default


    Interesting.
    Flash and AIR do provide sockets based on TCP, which maintain a connection and won't scale.
    However they work very well in a minor environment.

    Do you know any browser plugin that supports listening UDP sockets? Since UDP is connectionless it would scale much better.

    Regards

    Wolfgang