ASP Simple Chat Room program two

Source: Internet
Author: User

ASP Simple Chat Room program two

<% @Language = "JavaScript" codepage= "936"%><%
var nothing;
Response.AddHeader ("Cache-control", "No-cahce");
if (! Session.Contents ("Chat_user"))
{
Session.Contents ("chat_user") = "Guest";
Session.Contents ("chat_time") = (new Date). GetTime ();
}
if (application.contents ("chat_data") = = Nothing)
{
Application.Lock ();
Application.Contents ("chat_data") = "F system bredb you bblueb Welcome to the chat room. BBLACKB "+ (3000 + (new Date). GetTime ());
Application.UnLock ();
}
var postchat = Request.QueryString.Item;
if (postchat)
{
var chat_data = application.contents ("Chat_data"). Split ("F");
if (Chat_data.length >) chat_data.shift ();
Chat_data.push (Server.HTMLEncode (unescape (postchat)) + "B" + (new Date). GetTime ());
Application.Lock ();
Application.Contents ("chat_data") = Chat_data.join ("f");
Application.UnLock ();
}
var lasttime = session.contents ("Chat_time");
var MyData = new Array;
var alldata = application.contents ("Chat_data"). Split ("F");
for (Var c=alldata.length-1; c>=1; c--)
{
var Node = new Array;
var Item = Alldata[c].split ("B");
if (Item[6] <= session.contents ("Chat_time")) break;
if (Item[6] > Lasttime) lasttime = item[6];
Node.push ("< Sender color =" "+ item[1] +" ">" + item[0] + "</sender >");
Node.push ("< Receiver color =" "+ item[3] +" ">" + item[2] + "</receiver >");
Node.push ("< speak color =" "+ item[5] +" ">" + item[4] + "</talk >");
Node = Node.join ("ttrn");
node = "t< Chat time =" "+ item[6] +" ">" + node + "rnt</chat >";
Mydata.push (Node);
}
Session.Contents ("chat_time") = Lasttime;
Mydata.reverse ();
%><?xml version= "1.0" encoding= "gb2312"?>
< chat room >
<%=mydata.join ("RN")%>
</Chat Room >

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.