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

ASP
绑定txt文件到DataGrid
在用户离开页面时提示信息
asp + oracle 分页方法(不用存储过程)
asp + sqlserver 分页方法(不用存储过程)
验证身份证号是否正确的代码
检查有日文片假名的新闻
asp关键字函数运算附
ASP中也能解压缩rar文件
ASP文章系统解决方案
DW+ASP 玩转动态二级菜单
在ASP中操作数据库的方法
ASP做象资源管理器的树形目录
在asp中结合对象和组件
Active Server Pages是什么?
ActiveServerPages是怎样工作?
ASP脚本基础
ASP中的内建对象Server
在网页中动态的生成一个gif图片
ASP.NET中的状态管理
解决ASP执行DB查询中的特殊字符问题

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 138 ::
收藏到网摘: 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