ASP編程入門進階(十一):Chat 聊天程式

來源:互聯網
上載者:User
通常的聊天室所採用的程式,也就是Chat程式了,其基本結構原理是不會採用到資料庫的。那究竟採用什麼技術呢?我們知道ASP變數當中Session變數的作用是記錄單個使用者的資訊,並且能跟蹤使用者的行為。
  Application對象的作用則起的全域變數,可以實現網站多個使用者之間在頁面中共用資訊的。
  那可以想象,在針對當前聊天程式中,一個聊天成員即為一個Session變數,聊天成員之間的會話則當成Application變數進行共用顯示,以使各成員都能看見。
  那下面就採用一很經典的執行個體程式,進行瞭解和分析。
  1,chat.asp
<%If Request.ServerVariables("Request_Method")="GET" then%> <form method="post" action="chat.asp"> <input type="text" name="nick" value="your nick name"><p> <input type="submit" value="come in"><p> <input type="hidden" name="log" size="20" value="1"> </form><%Response.End Else Response.clear dim talk If Request.Form("nick")<>"" then Session("nick")=Request.Form("nick") End if%><form method="post" action="chat.asp" name=form1> <%=Session("nick")%>說話: <input type="text" name="talk" size="50"><br> <input type="submit" value="提交"> <input type="reset" value="取消"></p></form><a href="chat.asp">離開</a><br><%If Request.Form("log")<>1 then If trim(Request.Form("talk"))="" then talk=Session("nick")&"不說一句話就想來敷衍大家" Else talk=trim(Request.Form("talk")) End If Application.lock Application("show")="來自"&Request.ServerVariables("remote_addr")& "的_" &Session("nick")&"在"&time& "的時候說:" &talk& "<br>" &Application("show") Application.UnLock Response.Write Application("show")End if%>
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.