[Chilli] Show a notification when a user's session is about to end

Gergely Kiss mail.gery at gmail.com
Mon Mar 14 19:19:33 UTC 2011


Hi Jonas,

I don't use the latest release of CoovaChilli, so this method may not work
for versions newer than 1.2.2. But it worths a try...

Some time ago I created a slightly modified version of the JSON interface -
it was extremely easy to customize the code, even for me (I'm not a JS
expert).

This function should do the work:

var userNotified = false;

// Shows a notification if session timeout is about to expire
function timeoutNotification () {
   var notifyLimit = 600; // Set the notification limit here in seconds (10
minutes by default)
   var tSessionTime = parseInt ( chilliController.accounting.sessionTime ,
10 ) ;
   var tSessionTimeout = parseInt ( chilliController.session.sessionTimeout
, 10 ) ;
   var tRemaining = tSessionTimeout - tSessionTime;
   if ( tRemaining < notifyLimit && userNotified == false ) {
      alert('Your session is about to end in ' + Math.floor (tRemaining /
60) + ' minutes.');
      userNotified = true;
   }
}

These lines should be put to the top of chilliController.js. You also need
to actually call this function somewhere in the code, the best place would
be the "updateUI" function, which runs each time the timer specified in
chilliLibrary.js expires ("interval"):

function updateUI (cmd ) {
[...]

    if ( chilliController.clientState == 1 ) {
        if ( chilliController.statusURL ) {
       chilliController.statusWindow =
window.open(chilliController.statusURL, "");
    } else {
       showStatusPage();
*       // notifies user before the session times out
       timeoutNotification();*
       setDirtyFlag();
        }
    }

[...]
}

I've set the timeout to 5 seconds, so at most 5 seconds after the specified
notification limit, the warning message will be presented to the user.

I'm not able to test the code right now, but hopefully it's simple enough to
work out of the box...

The customized version of the JSON interface is also attached for you - you
just have to put the files into the "www" folder of your CoovaChilli
installation (generaly to /etc/chilli/www) and put your network name and
logo to "index.html" and "splash.html".


Regards,
Gergely

On 7 March 2011 15:01, Jonas Wouters <hello at jonaswouters.be> wrote:

> Hi,
>
> We are looking for a way to warn a user if his session is about to end.
>  Without working with a separate popup.
>
> A user has a session length of about 60 minutes. Somehow we would like to
> notify the user at around 50 minutes that he is nearing the end.  All the
> connections should be able to stay open so closing the session early and
> opening a new session directly on the login/notification page  would not be
> an option.
>
> Anyone got any tips or experience he/she would like to share on this
> matter?
>
> Thanks
> Jonas
>
>
>
> _______________________________________________
> Chilli mailing list
> Chilli at coova.org
> http://lists.coova.org/cgi-bin/mailman/listinfo/chilli
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.coova.org/pipermail/chilli/attachments/20110314/79f84068/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: chilli_www_json.zip
Type: application/zip
Size: 23833 bytes
Desc: not available
URL: <http://lists.coova.org/pipermail/chilli/attachments/20110314/79f84068/attachment-0001.zip>


More information about the Chilli mailing list