server/lib/GG-Gateway.js
function SetCrontab (gateway, inactivity) {
    // let's call back ourself after inactivity*1000/4
    gateway.Debug (5, "SetCrontab inactivity=%d", inactivity);
    setTimeout (function(){SetCrontab (gateway, inactivity);}, inactivity*250);
    
    // let compute inactivity timeout limit
    var timeout = new Date().getTime() - (inactivity *1000);
    
    for (var devid in gateway.activeClients) {
        var device = gateway.activeClients[devid];
        if (device.lastshow < timeout) {
            gateway.Debug (1, "Removed ActiveDev Id=%s uid=%s", device.devid, device.uid);
            delete gateway.activeClients [devid];
        }
    }
      
}
function SetCrontab (gateway, inactivity) {
    // let's call back ourself after inactivity*1000/4
    gateway.Debug (5, "SetCrontab inactivity=%d", inactivity);
    setTimeout (function(){SetCrontab (gateway, inactivity);}, inactivity*250);
    
    // let compute inactivity timeout limit
    var timeout = new Date().getTime() - (inactivity *1000);
    
    for (var devid in gateway.activeClients) {
        var device = gateway.activeClients[devid];
        if (device.lastshow < timeout) {
            gateway.Debug (1, "Removed ActiveDev Id=%s uid=%s", device.devid, device.uid);
            delete gateway.activeClients [devid];
        }
    }
      
}
function SetCrontab ( gateway , inactivity ) { // let's call back ourself after inactivity*1000/4 gateway . Debug ( 5 , "SetCrontab inactivity=%d" , inactivity ) ; setTimeout ( function ( ) { SetCrontab ( gateway , inactivity ) ; } , inactivity * 250 ) ; // let compute inactivity timeout limit var timeout = new Date ( ) . getTime ( ) - ( inactivity * 1000 ) ; for ( var devid in gateway . activeClients ) { var device = gateway . activeClients [ devid ] ; if ( device . lastshow < timeout ) { gateway . Debug ( 1 , "Removed ActiveDev Id=%s uid=%s" , device . devid , device . uid ) ; delete gateway . activeClients [ devid ] ; } } }
30s in between two retry this function scan active device table and remove dead one based on inactivity timeout
30s in between two retry this function scan active device table and remove dead one based on inactivity timeout