当前位置: 首页 > 图文教程 > 网络编程 > ASP > 用ASP实现号码转换程序实例

ASP
Server Application Error错误解决思路
ASP教程:在IIS环境下自己设置404页面
ASP代码出现80040e14错误的解决方法
Http_Referer,Server_Name和Http_Host
HTTP_X_FORWARDED_FOR和REMOTE_ADDR
总结的Server.Mappath的用法
巧用ASP脚本命令重启服务器
实现数字字符串的最大值、最小值和平均值
详解ASP脚本的执行顺序
理解认识阿里妈妈淘客系统对外接口通用规范
网站开发者参考:开源ASP网站源码
IIS管理程序Adsutil.vbs修改FTP服务器的PASV端口范围
ASP程序中调用函数Now()异常的问题
流量大的网站不要选择万能空间
网站挂马方式大总结
启动 W3SVC 服务报错怎么解决
Vista系统安装IIS7配置ASP运行环境
Server Application Error 8004EOOF错误
ASP不用模板直接简单生成HTML页面
ASP教程:gb2312和utf-8乱码问题解决

用ASP实现号码转换程序实例


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 184 ::
收藏到网摘: n/a

  在编聊天室时,处理用户断线是一个刺手的问题,特别是放到免费网站上,如果一味地靠global.asa,什么时候触发session_onend,application_onend,都是一个不确定的数字,在设计时,合理地安排会带来意想不到的好处。
那么有什么最简便办法处理用户断线呢?
笔者经过试验,有了以下的方法:
聊天室用N个application("user" & N)来保存用户名,再用application("TimeBegin")来保存每个用户的登录时间,同时,在用户登录时用session("TimerBegin")保存登录时间(timer),在发言区设定刷新时间为N秒,每次刷新将session("TimeBegin")的时间更新,同时判断timer - application("user"&session(userID)) 是否>N秒,如果是则说明该用户没有自动刷新,即意味着已经断线,即可将该application("user"&N)设为空值,再提示该用户已退出即可。
部分代码:
total = application("AllPeople")'聊天总人数
aryHuman = split(total,";")
for i = lbound(aryHuman) to ubound(aryHuman) - 1
if application("user" & i) = "online" then
if int(timer) - int(application("TimeBegin" & i)) > 120 then
application("user" & i) = ""
temp = aryHuman(i)
aryName = split(temp,",")
hrefname = aryName(0)
for j = lbound(aryHuman) to ubound(aryHuman) - 1
if application("user" & j) = "online" then
application("content" & j) = "<FONT color=#000000>【公告】"&hrefname&"</FONT>" &"<font color=#F08000
>"& "断线..." & "</font><font color = #000000 class=p9>" & " <" & time() & "></font><br>" & application
("content" & j)
end if
next
end if
end if
next