KeepAlive for the DotImage WebImageViewer

Published 31 December 08 08:22 AM | jacobl 

Recently, I posted an article describing a simple way to keep a session alive during long periods of inactivity. That works great if your web application doesn't rely on some other information on the server to maintain state. If you use DotImage in your web app, it maintains certain state information in the AtalaCache that needs to be updated every so often. If not, you run the risk of another user hitting the page and causing the AtalaCache to be cleaned up (assuming the cache has expired). This post explains how to avoid this by forcing the WebImageViewer to update its timestamps on your state.

Server Side

In your page's code behind, add the following RemoteInvokable function:

   1: [RemoteInvokable]
   2: public void Remote_KeepSessionAlive()
   3: {
   4:     // Don't need to do anything here.
   5:     // A simple page request will force the
   6:     // WebImageViewer to update any timestamps 
   7:     // it needs for this session.
   8: }

Client Side

In your aspx page, add the following JavaScript:

   1: function KeepAlive(){
   2:     WebImageViewer1.RemoteInvoke('Remote_KeepSessionAlive');
   3: }
   4: setInterval('KeepAlive();', '900000');

We don't need to pass anything into the RemoteInvoke and we don't need to set an event handler for the return since it doesn't matter to us. Very simple.

This RemoteInvoke-based keepalive for the DotImage WebImageViewer will fire every 15 minutes (or 900,000 milliseconds == half of my session lifetime). Make sure you adjust that duration according to your server's session. Be sure to set it to something less than your session timeout or you might miss it.

Comments

# KeepAlive for the DotImage WebThumbnailViewer | Games Money said on January 9, 2009 9:02 AM:

PingBack from http://games-money.com/blog/2009/01/09/keepalive-for-the-dotimage-webthumbnailviewer/

Anonymous comments are disabled