flex SystemManger flex SystemManger监控用户是否和程序打交道

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

flex SystemManger flex SystemManger监控用户是否和程序打交道

  2021-03-17 我要评论
想了解flex SystemManger监控用户是否和程序打交道的相关内容吗,在本文为您仔细讲解flex SystemManger的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:flex,SystemManger,下面大家一起来学习吧。
例如:
var sysMan:SystemManager = Application.application.systemManager;
sysMan.removeEventListener(FlexEvent.IDLE, timeoutHandler);
// timeout after twenty seconds
public var timeout:Number = 20000;
private var timeoutTotal:Number = 0;
private var timeoutLastCall:Number;
public var sessionExpired:Boolean = false;
public var enableTimeout:Boolean = true;
private function timeoutHandler(event:FlexEvent):void
{
// get current time
var curTime:int = getTimer();
var timeDiff:int = 0;
if (isNaN(timeoutLastCall)) {
timeoutLastCall = curTime;
}
timeDiff = curTime - timeoutLastCall;
timeoutLastCall = curTime;
// if time has passed since the idle event we assume user is interacting
// reset time total - otherwise increment total idle time
if (timeDiff > 1000) {
timeoutTotal = 0;
}
else {
// update time
// the status field will not be updated unless the application is idle
// it is only display a countdown for learning purposes
timeoutTotal += 100;
status.text = "Timeout in " + String(Number((timeout - timeoutTotal)/1000).toFixed(0)) + " seconds";
}
// if the total time of inactivity passes our timeout
// and the session already hasn't expired then logout user
if (timeoutTotal > timeout && !sessionExpired) {
// logout user
// or set flag
sessionExpired = true;
status.text = "timeout threshold has been reached";
//当时间超过之后执行的语句
sessionTimeoutHandler();
}
}

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们