XMLHTTP+javascript+Asp写得聊天室 无刷新实现(四)

2016-01-29 17:35 1 1 收藏

XMLHTTP+javascript+Asp写得聊天室 无刷新实现(四),XMLHTTP+&#106avascript+Asp写得聊天室,无刷新实现(四)

【 tulaoshi.com - ASP 】

  ########say.asp##############

<% Option Explicit
dim F,T,sC,cL,E,W,sJ
Response.ContentType="text/xml"
F=Request.Form ("F")
T=Request.Form ("T")
sC=Request.Form ("sC")
cL=Request.Form ("cL")
E=Request.Form("E")
'W=Request.Form("W")
W="0"
'发言时间
sJ=getTime()
if Request.ServerVariables("REQUEST_METHOD")="POST" then
sC="<F"&trim(F)&"</F<T"&trim(T)&"</T<E"&E&"</E<sC"&trim(sC)&"</sC<cL"&trim(cL)&"</cL<sJ"&sJ&"</sJ"
else
Response.End
end if
dim c_info,c_Lid,c_Ip,u_Lid,NewLid,u_name,i
Application.Lock
c_info=Application("c_info")
c_Lid=Application("c_Lid")+1
Application("c_Lid")=c_Lid
c_Ip=(c_info(0)+6) mod 240
c_info(0)=c_Ip
c_info(c_Ip)=c_Lid
c_info(c_Ip+1)=F
c_info(c_Ip+2)=T
c_info(c_Ip+3)=W
c_info(c_Ip+4)=""
c_info(c_Ip+5)=sC '"<F"&trim(F)&"</F<T"&trim(T)&"</T<E"&E&"</E<sC"&trim(sC)&"</sC<cL"&trim(cL)&"</cL<sJ"&sJ&"</sJ"
Application("c_info")=c_info
Application.UnLock
u_Lid=session("u_Lid")
newLid=u_Lid
u_name=session("u_name")
'&Application("c_Lid")&"%"&c_info(0)

Response.Write "<?xml version=""1.0""?<Msg"
for i=c_info(0)+6 to 240 step 6
if (c_info(i)u_Lid) and ((c_info(i+1)=u_name) or (c_info(i+2)=u_name) or (c_info(i+2)="大家") or (c_info(i+3)="0")) then
Response.Write c_info(i+5)
if (newLid<c_info(i)) then newLid=c_info(i)
end if
next
for i=1 to c_info(0) step 6
if (c_info(i)u_Lid) and ((c_info(i+1)=u_name) or (c_info(i+2)=u_name) or (c_info(i+2)="大家") or (c_info(i+3)="0")) then
Response.Write c_info(i+5)
if (newLid<c_info(i)) then newLid=c_info(i)
end if
next

Response.Write "</Msg"
session("u_Lid")=newLid

function getTime()
dim y,m,d,h,n,s
y=Year(date())
m=Month(date())
d=Day(date())
h=Hour(time())
n=Minute(time())
s=Second(time()) '当为是一位的 时候在前面加0
if len(m)=1 then m="0" & m
if len(d)=1 then d="0" & d
if len(h)=1 then h="0" & h
if len(n)=1 then n="0" & n
if len(s)=1 then s="0" & s
getTime=y&"/"&m&"/"&d &" " & h&":"& n&":"&s
end function%



 

来源:https://www.tulaoshi.com/n/20160129/1502046.html

延伸阅读
标签: ASP
  合肥 程双明         经 常 在Internet 上 冲 浪 的 网 友 恐 怕 很 少 有 人 没 有 去 过 聊 天 室 胡乱神聊。 你 只 要 稍 微 留 意 一 下 就会 发 现 这 些 聊 天 室 大 多 是 用CGI 程 序 或 者 用JAVA 开 发 的 Applet 维 护 的。 开 发 过 这 类CGI 或Applet ...
标签: ASP
  聊天室是网络实时交互的最常应用之一。聊天室的制作要解决好以下问题。 1、谁在发言 2、讲给谁听 3、讲些什么 与ICQ不同,ICQ 的数据流是一对一的关系。只要解决好上面三个问题就 可以实现。 聊天室由于存在一对多、多对一、一对一等多种数据关系,因此就有一个 数据的存放问题。 ASP 聊天室的数据存放一般有三种形式: 一是用全局变量A...
标签: ASP
  作者:网络之门    聊天室程序是一个application和session对象结合性很强的asp程序。首先,它比较具有实时性,聊天速度太慢,那么没有人会喜欢的,而且在多人同时发言的时侯,如果程序处理不好,那么难免会发生张官李戴的现象,比如说明明张三说的话在先。李四说的话在后,但显示出来的结果却是倒转了。还有就...
标签: ASP
  作者:网络之门 几个要好的网友在聊天室里闲聊的时侯,总会遇上有些话题是不想同一聊天室内别的聊友看见的,那么聊天室支持悄悄话功能将是什分有必要的了,实现悄悄话的方法很多,现在小虎介绍一下利用session对象来实现它,用session对象来实现悄悄话,是有优缺点的,因为session对象的应用,其实就是客户端cookies的...
标签: ASP
  作者:网络之门 上两节介绍了如何处理聊天室内的谈话内容以及悄悄话的特殊处理,至此。我们去看看谈话内容是如何在客户端显示出来的。请先看看我们的显示对话文件(top.asp) *top.asp <% @language="vbscript" % <% Response.Expires=0 'response.buffer=true % ...

经验教程

10

收藏

7
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部