聊天室实现私聊第1/4页
程序员文章站
2022-07-02 07:53:55
几个要好的网友在聊天室里闲聊的时侯,总会遇上有些话题是不想同一聊天室内别的聊友看见的,那么聊天室支持悄悄话功能将是什分有必要的了,实现悄悄话的方法很多,现在小虎介绍一下利用...
几个要好的网友在聊天室里闲聊的时侯,总会遇上有些话题是不想同一聊天室内别的聊友看见的,那么聊天室支持悄悄话功能将是什分有必要的了,实现悄悄话的方法很多,现在小虎介绍一下利用session对象来实现它,用session对象来实现悄悄话,是有优缺点的,因为session对象的应用,其实就是客户端cookies的使用。如果客户端cookies不支持或关闭了,那么程序运行起来就有问题了。那么使用session对象就没好处了吗??非也,至少在编程上大大减少了工作量嘛,试想一下如果需要保存该用户的聊天名字,那么使用session对象就能直接保存他的名字了,如果没有session对象。解决的方法看来就只有在处理发言的form里设几个隐含的textbox对象来保存,这样处理起来会比教烦锁,但好处是通用性广,就算浏览器不支持cookies仍然可用。
说到这里,大伙不妨试试网上众多的asp聊天室,试把浏览器的安全选项(总是接受cookies关了)看看那个聊天室仍然正常地能使用。那个就问题百出来。。呵呵~~不要找小虎的聊天室来试哦....我的聊天室也需要cookies来支持的。不用session对象编程真是烦锁很多。而且大部分浏览器的安全配置的默认值是总是接受cookies。所以也不用太但心,只有少部分的用户是比教特别的。
现在从聊天室的发言开始,到处理发言,显示发言,一步一步地让大家了解一下是如何处理的,最后就加上悄悄话功能
首先,我们的聊天室主要提供如下元素:发言人(你的名字),动作(叫嚷,抱抱...等),对象(这句话是向谁说的呢?),发言内容等四大元素。
其中发言人(你的聊天名字)的名字是保存在发言form的user隐藏文本框中,这样每当发言的时侯,在处理发言的says.asp程序里,就可以用request.form("user")来取得聊天名字。而动作则是由下拉框action来提供的,你可以自定义很多的动作类型,以满足不同聊友的需要。而发言对象,也是由下拉框whoto来选定,这些名单是列出当前聊天室内所有用户的名称。如何判断有新用户进聊天室以及退出处理,这里先不说了。因为构造一个完整的聊天室要做的工作还是挺多的。最后由一个says文本框提供发言内容。
有了这几个主要的聊天元素。我们就可以进行发言处理了。
请看看下面的程序片段
'取得说话内容,并过滤其中的脚本语句
usersays=request.form("says")
if instr(usersays,"<script")>0 then
usersays=""
end if
'判断是否有谈话内容,没有的话就不作处理
if len(usersays)<>0 then
session("whoto")=request.form("whoto")
session("action")=request.form("action")
if instr(usersays,chr(39))>0 then
usersays=replace(usersays,chr(39),"\"&chr(39))
end if
if instr(usersays,chr(34))>0 then
usersays=replace(usersays,chr(34),"\"&chr(34))
end if
application.lock
'定义一个交谈缓冲区,后面将给大家仔细分析一下
dim chats(20)
for n=1 to 20
chats(n)=application("chats")(n)
next
username=request.form("user")
usertime=time
usertime="("&right(usertime,8)&")"
user_whoto=request.form("whoto")
user_action=request.form("action")
if application("counter")>19 then
application("counter")=0
end if
'不是耳语就加一
if request.form("action")<>"耳语" then
application("counter")=application("zj_1counter")+1
counter=application("zj_1counter")
'用户的动作处理
select case request.form("action")
case "说话"
if request.form("whoto")="all" then
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> :<font color=#0000aa> "&usersays&"</font><br><br>"
else
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>与<font color=#00bb00> "&request.form("whoto")&" </font>说</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
end if
case "叫嚷"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>冲<font color=#00bb00> "&request.form("whoto")&" </font>大叫</i>:<b><font color=#0000aa> "&usersays&"</font></b><br><br>"
case "亲亲"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>亲了亲<font color=#00bb00> "&request.form("whoto")&" </font>的脸颊</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "拥抱"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>轻轻的抱着<font color=#00bb00> "&request.form("whoto")&" </font></i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "暴怒"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>朝<font color=#00bb00> "&request.form("whoto")&" </font>横眉竖目道</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "轻推"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>轻轻地推了推<font color=#00bb00> "&request.form("whoto")&" </font>的胳膊</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "傻笑"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>傻兮兮的朝<font color=#00bb00> "&request.form("whoto")&" </font>笑笑</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "拳打"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>对准<font color=#00bb00> "&request.form("whoto")&" </font>就是一拳</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "脚踢"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>凌空一腿踢在<font color=#00bb00> "&request.form("whoto")&" </font>脑袋上</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "告戒"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>拉着<font color=#00bb00> "&request.form("whoto")&" </font>手语气心长地说</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "耳光"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>狠狠地掴了<font color=#00bb00> "&request.form("whoto")&" </font>几个耳光</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "鞠躬"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>毕恭毕敬地向<font color=#00bb00> "&request.form("whoto")&" </font>弯腰鞠躬</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "歉意"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>感到十二分的歉意,低声对<font color=#00bb00> "&request.form("whoto")&" </font>说</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "惊讶"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>惊讶的对<font color=#00bb00> "&request.form("whoto")&" </font>吐了吐舌头</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "哈欠"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>对<font color=#00bb00> "&request.form("whoto")&" </font>张大嘴巴,打了个哈欠</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "微笑"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>对<font color=#00bb00> "&request.form("whoto")&" </font>微微一笑</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "握手"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>紧紧的握住<font color=#00bb00> "&request.form("whoto")&" </font>的手</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "耸肩"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>对着<font color=#00bb00> "&request.form("whoto")&" </font>耸耸双肩</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "安慰"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>拍拍<font color=#00bb00> "&request.form("whoto")&" </font>的肩膀,双眼关切的说</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "生气"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>气鼓鼓的嘟嘴对<font color=#00bb00> "&request.form("whoto")&" </font>道</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "大哭"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>忍不住对着<font color=#00bb00> "&request.form("whoto")&" </font>放声大哭</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "抽泣"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>双手捂着脸,对着<font color=#00bb00> "&request.form("whoto")&" </font>呜呜咽咽的</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "承诺"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>对着<font color=#00bb00> "&request.form("whoto")&" </font>把胸脯拍得噼啪响</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "不舍"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>依依不舍地拉着<font color=#00bb00> "&request.form("whoto")&" </font>的衣角</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "深情"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>用深情的眼神,痴痴地看着<font color=#00bb00> "&request.form("whoto")&" </font></i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "迷惑"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>抓抓头皮看着<font color=#00bb00> "&request.form("whoto")&" </font>露出迷惑的神情</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "不解"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>用不可思意的眼神看着<font color=#00bb00> "&request.form("whoto")&" </font></i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "幸灾"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>幸灾乐祸地对<font color=#00bb00> "&request.form("whoto")&" </font>说</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "大笑"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>对着<font color=#00bb00> "&request.form("whoto")&" </font>捧腹大笑</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "皱眉"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>皱着眉头对<font color=#00bb00> "&request.form("whoto")&" </font></i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "委屈"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>很委屈地看着<font color=#00bb00> "&request.form("whoto")&" </font>眼泪哗啦啦地往下流</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "高兴"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>兴高采烈地对<font color=#00bb00> "&request.form("whoto")&" </font>说</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "沮丧"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>满脸沮丧地对<font color=#00bb00> "&request.form("whoto")&" </font>说</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "失望"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>垂头丧气地对<font color=#00bb00> "&request.form("whoto")&" </font>说</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "神经"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>神经兮兮地对<font color=#00bb00> "&request.form("whoto")&" </font>说</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "神秘"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>非常神秘地对<font color=#00bb00> "&request.form("whoto")&" </font>说</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "撒娇"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>拉着<font color=#00bb00> "&request.form("whoto")&" </font>手撒娇</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "鬼脸"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>对着<font color=#00bb00> "&request.form("whoto")&" </font>做了个鬼脸</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "无奈"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>对着<font color=#00bb00> "&request.form("whoto")&" </font>很无奈地</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
end select
'是耳语
else
'耳语处理
application("chat")="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>悄悄地对<font color=#00bb00> "&request.form("whoto")&" </font>耳语</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
'对谁说
application("chatto")=request.form("whoto")
'说话的人
application("owner")=username
session("chat")="true"
end if
'谈话全局化
application("chats")=chats
application.unlock
end if
上面的程序是把用户的发言和动作以及说话对象生成html语句并保存起来。用以后面的在聊天室中显示出来,其中请大家注意一下耳语是保存在application("chat")这个全局应用程序对象中的。好了,下节先为大家详细分析一下说话的内容是如何处理。
说到这里,大伙不妨试试网上众多的asp聊天室,试把浏览器的安全选项(总是接受cookies关了)看看那个聊天室仍然正常地能使用。那个就问题百出来。。呵呵~~不要找小虎的聊天室来试哦....我的聊天室也需要cookies来支持的。不用session对象编程真是烦锁很多。而且大部分浏览器的安全配置的默认值是总是接受cookies。所以也不用太但心,只有少部分的用户是比教特别的。
现在从聊天室的发言开始,到处理发言,显示发言,一步一步地让大家了解一下是如何处理的,最后就加上悄悄话功能
首先,我们的聊天室主要提供如下元素:发言人(你的名字),动作(叫嚷,抱抱...等),对象(这句话是向谁说的呢?),发言内容等四大元素。
其中发言人(你的聊天名字)的名字是保存在发言form的user隐藏文本框中,这样每当发言的时侯,在处理发言的says.asp程序里,就可以用request.form("user")来取得聊天名字。而动作则是由下拉框action来提供的,你可以自定义很多的动作类型,以满足不同聊友的需要。而发言对象,也是由下拉框whoto来选定,这些名单是列出当前聊天室内所有用户的名称。如何判断有新用户进聊天室以及退出处理,这里先不说了。因为构造一个完整的聊天室要做的工作还是挺多的。最后由一个says文本框提供发言内容。
有了这几个主要的聊天元素。我们就可以进行发言处理了。
请看看下面的程序片段
'取得说话内容,并过滤其中的脚本语句
usersays=request.form("says")
if instr(usersays,"<script")>0 then
usersays=""
end if
'判断是否有谈话内容,没有的话就不作处理
if len(usersays)<>0 then
session("whoto")=request.form("whoto")
session("action")=request.form("action")
if instr(usersays,chr(39))>0 then
usersays=replace(usersays,chr(39),"\"&chr(39))
end if
if instr(usersays,chr(34))>0 then
usersays=replace(usersays,chr(34),"\"&chr(34))
end if
application.lock
'定义一个交谈缓冲区,后面将给大家仔细分析一下
dim chats(20)
for n=1 to 20
chats(n)=application("chats")(n)
next
username=request.form("user")
usertime=time
usertime="("&right(usertime,8)&")"
user_whoto=request.form("whoto")
user_action=request.form("action")
if application("counter")>19 then
application("counter")=0
end if
'不是耳语就加一
if request.form("action")<>"耳语" then
application("counter")=application("zj_1counter")+1
counter=application("zj_1counter")
'用户的动作处理
select case request.form("action")
case "说话"
if request.form("whoto")="all" then
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> :<font color=#0000aa> "&usersays&"</font><br><br>"
else
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>与<font color=#00bb00> "&request.form("whoto")&" </font>说</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
end if
case "叫嚷"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>冲<font color=#00bb00> "&request.form("whoto")&" </font>大叫</i>:<b><font color=#0000aa> "&usersays&"</font></b><br><br>"
case "亲亲"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>亲了亲<font color=#00bb00> "&request.form("whoto")&" </font>的脸颊</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "拥抱"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>轻轻的抱着<font color=#00bb00> "&request.form("whoto")&" </font></i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "暴怒"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>朝<font color=#00bb00> "&request.form("whoto")&" </font>横眉竖目道</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "轻推"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>轻轻地推了推<font color=#00bb00> "&request.form("whoto")&" </font>的胳膊</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "傻笑"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>傻兮兮的朝<font color=#00bb00> "&request.form("whoto")&" </font>笑笑</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "拳打"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>对准<font color=#00bb00> "&request.form("whoto")&" </font>就是一拳</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "脚踢"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>凌空一腿踢在<font color=#00bb00> "&request.form("whoto")&" </font>脑袋上</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "告戒"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>拉着<font color=#00bb00> "&request.form("whoto")&" </font>手语气心长地说</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "耳光"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>狠狠地掴了<font color=#00bb00> "&request.form("whoto")&" </font>几个耳光</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "鞠躬"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>毕恭毕敬地向<font color=#00bb00> "&request.form("whoto")&" </font>弯腰鞠躬</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "歉意"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>感到十二分的歉意,低声对<font color=#00bb00> "&request.form("whoto")&" </font>说</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "惊讶"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>惊讶的对<font color=#00bb00> "&request.form("whoto")&" </font>吐了吐舌头</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "哈欠"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>对<font color=#00bb00> "&request.form("whoto")&" </font>张大嘴巴,打了个哈欠</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "微笑"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>对<font color=#00bb00> "&request.form("whoto")&" </font>微微一笑</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "握手"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>紧紧的握住<font color=#00bb00> "&request.form("whoto")&" </font>的手</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "耸肩"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>对着<font color=#00bb00> "&request.form("whoto")&" </font>耸耸双肩</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "安慰"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>拍拍<font color=#00bb00> "&request.form("whoto")&" </font>的肩膀,双眼关切的说</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "生气"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>气鼓鼓的嘟嘴对<font color=#00bb00> "&request.form("whoto")&" </font>道</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "大哭"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>忍不住对着<font color=#00bb00> "&request.form("whoto")&" </font>放声大哭</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "抽泣"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>双手捂着脸,对着<font color=#00bb00> "&request.form("whoto")&" </font>呜呜咽咽的</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "承诺"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>对着<font color=#00bb00> "&request.form("whoto")&" </font>把胸脯拍得噼啪响</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "不舍"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>依依不舍地拉着<font color=#00bb00> "&request.form("whoto")&" </font>的衣角</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "深情"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>用深情的眼神,痴痴地看着<font color=#00bb00> "&request.form("whoto")&" </font></i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "迷惑"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>抓抓头皮看着<font color=#00bb00> "&request.form("whoto")&" </font>露出迷惑的神情</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "不解"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>用不可思意的眼神看着<font color=#00bb00> "&request.form("whoto")&" </font></i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "幸灾"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>幸灾乐祸地对<font color=#00bb00> "&request.form("whoto")&" </font>说</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "大笑"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>对着<font color=#00bb00> "&request.form("whoto")&" </font>捧腹大笑</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "皱眉"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>皱着眉头对<font color=#00bb00> "&request.form("whoto")&" </font></i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "委屈"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>很委屈地看着<font color=#00bb00> "&request.form("whoto")&" </font>眼泪哗啦啦地往下流</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "高兴"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>兴高采烈地对<font color=#00bb00> "&request.form("whoto")&" </font>说</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "沮丧"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>满脸沮丧地对<font color=#00bb00> "&request.form("whoto")&" </font>说</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "失望"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>垂头丧气地对<font color=#00bb00> "&request.form("whoto")&" </font>说</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "神经"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>神经兮兮地对<font color=#00bb00> "&request.form("whoto")&" </font>说</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "神秘"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>非常神秘地对<font color=#00bb00> "&request.form("whoto")&" </font>说</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "撒娇"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>拉着<font color=#00bb00> "&request.form("whoto")&" </font>手撒娇</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "鬼脸"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>对着<font color=#00bb00> "&request.form("whoto")&" </font>做了个鬼脸</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
case "无奈"
chats(counter)="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>对着<font color=#00bb00> "&request.form("whoto")&" </font>很无奈地</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
end select
'是耳语
else
'耳语处理
application("chat")="<font color=blue>"&usertime&"</font> <font color=black>"&username&"</font> <i>悄悄地对<font color=#00bb00> "&request.form("whoto")&" </font>耳语</i>:<font color=#0000aa> "&usersays&"</font><br><br>"
'对谁说
application("chatto")=request.form("whoto")
'说话的人
application("owner")=username
session("chat")="true"
end if
'谈话全局化
application("chats")=chats
application.unlock
end if
上面的程序是把用户的发言和动作以及说话对象生成html语句并保存起来。用以后面的在聊天室中显示出来,其中请大家注意一下耳语是保存在application("chat")这个全局应用程序对象中的。好了,下节先为大家详细分析一下说话的内容是如何处理。
1
下一篇: 多域名绑定到一个空间访问不同首页的技巧