用ASP实现内部网实时通讯,用APPLICATION,如何实现?

cih1981 2003-12-29 09:08:27
用ASP实现内部网实时通讯,用APPLICATION,如何实现?
想用asp做实时web通信
如果使用application的话,是不是为每个在线用户建立一个变量吧,或者利用字符串?
...全文
67 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
patchclass 2003-12-29
  • 打赏
  • 举报
回复
为每个在线用户建立一个变量
用 session
如果是一个公共变量 用application
两个结合的用
swich 2003-12-29
  • 打赏
  • 举报
回复
根据上面的代码找找思路
swich 2003-12-29
  • 打赏
  • 举报
回复
用session和application配合着用

<title>在线传讯</title>
<!--#include file="../css.asp"-->
<%
dim refreshtime,idletime,totalusers,onlineuser(),tmp(),num,i
refreshtime=10
idletime=refreshtime*3
newuser=request("username")
usermsg=newuser&"msg"
Application.Lock



if application(newuser&"lastaccesstime")=empty then
if application("totalusers")=empty then application("totalusers")=0
redim tmp(application("totalusers")+1)
num=0
if application("totalusers")>0 then
for i=lbound(application("onlineuser")) to ubound(application("onlineuser"))
user=application("onlineuser")(i)
if user<>newuser and user<>session("username") then
tmp(num)=user
num=num+1
else
application(user&"lastaccesstime")=empty
end if
next
end if
session("username")=newuser
tmp(num)=session("username")
application("totalusers")=num+1
redim preserve tmp(application("totalusers"))
application("onlineuser")=tmp
end if


application(session("username")&"lastaccesstime")=timer


redim tmp(application("totalusers"))
num=0
for i=0 to application("totalusers")-1
user=application("onlineuser")(i)
if (timer-application(user&"lastaccesstime"))<idletime then
tmp(num)=user
num=num+1
else
application(user&"lastaccesstime")=empty
application(usermsg)=empty
end if
next


if num<>application("totalusers") then
redim preserve tmp(num)
application("onlineuser")=tmp
application("totalusers")=num
end if
Application.UnLock
%>
<html>
<head>
<meta http-equiv="refresh" content="<%=refreshtime%> ,url=<%=Request.ServerVariables("path_info")%>?username=<%=request("username")%>">
<script language="vbscript">
sub openchat()
window.open "calling.asp","chatwindow","menubar=0,width=366,height=177"
end sub
</script>
</head>
<body leftmargin="0" topmargin="0" bgcolor="#F7F7F7">
<table width="120" cellspacing="1" cellpadding="0" width="100%" border="0" bgcolor="seagreen" align="center">
<tr>
<td align="center" height="20">
<font color="white" size="2">
<b>在线名单</b>
</font>
</td>
</tr>
<tr>
<td align="center" height="20">
<font color="white" size="2">
<b>共<%=application("totalusers")%>人</b>
</font>
</td>
</tr>
<tr bgcolor="#F7F7F7">
<td align="center">
<script language="JavaScript1.2">
iens6=document.all||document.getElementById
ns4=document.layers
var speed=6
if (iens6){
document.write('<div id="container" style="position:relative;width:120;height:190;overflow:hidden">')
document.write('<div id="content" style="position:absolute;width:120;left:0;top:0">')
}
</script>
<table cellspacing="1" cellpadding="0" width="100%" border="0" bgcolor="seagreen" align="center">
<%for i=0 to (application("totalusers")-1)%>
<tr bgcolor="#F7F7F7">
<td>
<font size="2"> <%=application("onlineuser")(i)%></font>
</td>
</tr>
<%next%>
</table>
<script language="JavaScript1.2">
if (iens6)
document.write('</div></div>')
</script>
</td>
</tr>
</table>
<table width="100%">
<tr bgcolor="#F7F7F7">
<td>
<img src="../../tu/1.gif" onmouseout="clearTimeout(movedownvar)" onmouseover="movedown()" style="CURSOR: hand" width="15" height="15"> <img src="../../tu/3.gif" style="CURSOR: hand" WIDTH="21" HEIGHT="15" onclick="openchat()"> <img src="../../tu/2.gif" onmouseout="clearTimeout(moveupvar)" onmouseover="moveup()" style="CURSOR: hand" width="15" height="15">
</td>
</tr>
</table>
<script language="JavaScript1.2">
if (iens6){
var crossobj=document.getElementById? document.getElementById("content") : document.all.content
var contentheight=crossobj.offsetHeight
}
else if (ns4){
var crossobj=document.nscontainer.document.nscontent
var contentheight=crossobj.clip.height
}

function movedown(){
if (iens6&&parseInt(crossobj.style.top)>=(contentheight*(-1)+100))
crossobj.style.top=parseInt(crossobj.style.top)-speed
else if (ns4&&crossobj.top>=(contentheight*(-1)+100))
crossobj.top-=speed
movedownvar=setTimeout("movedown()",100)
}

function moveup(){
if (iens6&&parseInt(crossobj.style.top)<=0)
crossobj.style.top=parseInt(crossobj.style.top)+speed
else if (ns4&&crossobj.top<=0)
crossobj.top+=speed
moveupvar=setTimeout("moveup()",100)

}

function getcontent_height(){
if (iens6)
contentheight=crossobj.offsetHeight
else if (ns4)
document.nscontainer.document.nscontent.visibility="show"
}
window.onload=getcontent_height
</script>
<%

if application(usermsg)<>"" then
application("showmsg")=application(usermsg)
%>

<%
session("winid")=session("winid")+1
session("userwinid")=newuser&session("winid")
%>
<script language="vbscript">
window.open "showmsg.asp","<%=session("userwinid")%>","menubar=0,width=366,height=210"
</script>
<%

application(usermsg)=empty
end if
%>
</body>
</html>

cih1981 2003-12-29
  • 打赏
  • 举报
回复
楼上的能具体说一下吗?
Tal 2003-12-29
  • 打赏
  • 举报
回复
用session

28,405

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧