Results 1 to 3 of 3

Thread: Detecting app activity for a 3rd party authentication server

  1. #1
    Sencha Premium Member
    Join Date
    Oct 2011
    Vote Rating

    Default Detecting app activity for a 3rd party authentication server

    Under a single sign-on setup I need to periodically grab an image from an authentication server. Normally this is done as each page is loaded, but in this case there aren't multiple pages. How can I detect activity across the app, in order to update the auth server with activity (to keep the session from timing out).

    I've thought about grabbing the image every time data is loaded, but this could result in the session timing out even though the user has been working with the grid full of data that didn't require server access. Also, there are 5 tabs with different kinds of interactivity, grids forms, etc. Some of that activity would result in XHRs, but not all of it, so I'm trying to find something that can worry about the whole interactivity problem outside of the actual app itself. Much like a screen saver watches over the use of anything on the desktop.

    I guess I'm looking for clicks and keystrokes mostly, not sure what else to count as activity (at the moment).

    How could you do this ext4

  2. #2
    Sencha User friend's Avatar
    Join Date
    Apr 2011
    Vote Rating


    Take a look at Ext.TaskManager. You can create a task to run on a specified interval and do whatever you want. I used Ext.TaskManager to create a session expiration checker task which alerts a user when they're within 60 seconds of a session timeout.

    It works quite nicely.

    In my case, I created a globally scoped 'sessionTask' object which has a 'lastActivity' property. I registered click events on the document object to reset the lastActivity date/time stamp, so each time the task ran, it would compare current datetime to the lastActivity datetime and decide what to do:

          // Any user click resets the last activity time on the global session
          // timeout task.
          Ext.EventManager.on(document, 'click', function() { 
   = (new Date()).getTime();
    You could obviously add a 'keypress' listener on the document as well, to have keystrokes reset the lastActivity value. I thought that approach was too chatty, from an event standpoint, so I just stuck with clicks.
    Last edited by friend; 12 Jan 2012 at 10:24 AM. Reason: spelling

  3. #3
    Sencha User hendricd's Avatar
    Join Date
    Aug 2007
    Long Island, NY USA
    Vote Rating



    Typically you would need to decide what constitutes an 'active session'.

    It might be any time:

    a) the user interacts with your service stack (Ajax)
    b) the user causes a field to change focus
    c) the user simply moves/clicks the mouse over/on the page
    d) keyPress?

    For any combination of the above, Class Observables and document-level listeners provide a centralized mechanism for monitoring such events without setting listeners on every component in your layouts.

    These events may also be buffered (say a 5 minute threshold), permitting periodic interaction with your server's session/state manager. Couple that with a Task that also runs every 5 minutes to see if anything has actually happened (else, react accordingly).
    "be dom-ready..."
    Doug Hendricks

    Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.

    Got Sencha licensing questions? Find out more here.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts