1. #1
    Ext User para's Avatar
    Join Date
    Apr 2007
    Location
    Redmond, WA
    Posts
    918
    Vote Rating
    -2
    para has a little shameless behaviour in the past

      0  

    Default Pinger - Sends requests at regular intervals

    Pinger - Sends requests at regular intervals


    This is a duplicate of a post in the 1.x forums, but it works on my 2.0 app, so I figured I'd add it here too...

    Here's a basic class I made to ping an address at regular intervals.
    I use this to keep the user's session alive while they are doing static work on the page. Essentially, while they are on a certain section of my page, there is the potential for their session to timeout, which should not occur.

    It extends Ext.data.Connection, so all the parameters of that are available. I provide a couple more: autoStart and timer.

    It doesn't have too many useful applications, but it does what I need it to.


    Example use:
    Code:
    configs:
      autoStart: 'true' to automatically start pinging immediately.
      timer: time between pings (approximate, depending on request time)
      params: params to include with the request.
    
    // This will request 'myPage.html' every 5 minutes.
    var pinger = new Pinger({url:'myPage.html', timer:300000, autoStart:true});
    
    //or
    
    var pinger = new Pinger({url:'myPage.html', timer:300000});
    pinger.start();

    EDIT:
    Some events are also provided:
    Code:
    pinger.on('beforeping', function() {});
    
    pinger.on('afterping', function(options, success, response) {});
    
    // can override callback (original callback is empty)
    pinger.callback = function(options, success, response) {}

    Updated to remove all defered ping calls when stopping. Possible for users to cause irregular pings if turning pinging on/off.
    Attached Files

  2. #2
    Ext User dantheman's Avatar
    Join Date
    Mar 2007
    Posts
    259
    Vote Rating
    1
    dantheman is on a distinguished road

      0  

    Default


    Hey Para,

    I've done something similar for our kerberized env.
    Because XHR's won't honor re-directs (in case of
    failed kerb auth), I had to use a hidden iframe for
    a full page load, but the idea is the same.

    Thanks for the extension.
    --dan

  3. #3
    Sencha User thejoker101's Avatar
    Join Date
    Mar 2007
    Posts
    348
    Vote Rating
    0
    thejoker101 is on a distinguished road

      0  

    Default


    Quote Originally Posted by dantheman View Post
    Hey Para,

    I've done something similar for our kerberized env.
    Because XHR's won't honor re-directs (in case of
    failed kerb auth), I had to use a hidden iframe for
    a full page load, but the idea is the same.

    Thanks for the extension.
    --dan
    Technically it will I believe. I've had XHR requests get redirected and of course Ext will handle it as a failure to connect and you can retrieve the status code via (for example a form): action.response.status (where action is the second argument in the fail callback)

  4. #4
    Ext User dantheman's Avatar
    Join Date
    Mar 2007
    Posts
    259
    Vote Rating
    1
    dantheman is on a distinguished road

      0  

    Default


    Quote Originally Posted by thejoker101 View Post
    Technically it will I believe. I've had XHR requests get redirected and of course Ext will handle it as a failure to connect and you can retrieve the status code via (for example a form): action.response.status (where action is the second argument in the fail callback)
    By honor, I meant do-the-right-thing ..

    Yes, I could wrap the XHR up to mimic a full page load behavior
    (and others have).. I just think a hidden iframe with a keepalive
    is conceptually simpler and better (as in likely more robust, imo).

    YMMV,
    --dan

  5. #5
    Ext User para's Avatar
    Join Date
    Apr 2007
    Location
    Redmond, WA
    Posts
    918
    Vote Rating
    -2
    para has a little shameless behaviour in the past

      0  

    Default


    This script works in several applications for me now. The original use was maintaining the session for when the user was on my design application page. Incredibly, the user has the potential to spend a full work day on the page without actually hitting any other pages.

    Since then I've used it for some automated pages which simply refresh, kind of like polling for info like system monitors and news collaboration page.

    I know it's a pretty simple structure, but it's come in handy for my needs.

Thread Participants: 2

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar