Chat Room A Few good friends in the chat room chatting, there are always some topics are not want the same chat room other chat friends see, then chat room to support the private message will be what is necessary, to achieve a lot of whispering methods, now the tiger introduced the use of the session object to achieve it, Using the session object to achieve private whispers, there are advantages and disadvantages, because the application of the session object, in fact, is the use of client cookies. If the client cookies are not supported or closed, then the program will run a problem. So is using the Session object No good?? Not also, at least programming greatly reduced workload, imagine if you need to save the user's chat name, then use the session object can directly save his name, if there is no session object. The solution seems to be that only a few hidden textbox objects are stored in the form where the address is addressed, which can be handled more than a boring lock, but the benefits are widespread, even if the browser does not support cookies still available.
Speaking of which, we may try the Internet's numerous ASP chat rooms, try to the browser's security options (always accept cookies off) to see that the chat room is still normal to use. That would be a problem. Oh ~ ~ Don't look for the tiger's chat room to try .... My chat room also needs cookies to support. No Session object programming is really annoying lock a lot. and the default value of most browsers ' security configuration is always to accept cookies. So there is no need to be too but the heart, only a small part of the user is more special than teaching.
Now from the chat room to start, to deal with the speech, show the speech, step-by-step to let everyone know how to deal with, and finally add a whisper function
First of all, our chat room mainly provides the following elements: spokesperson (your name), action (shouting, hugging ...) And so on), the object (to whom does this sentence say?) ), the content of the four elements.
The name of the spokesperson (your chat name) is saved in the User hidden text box in the statement form so that whenever you speak, you can use Request.Form ("user") to get the name of the chat in the Says.asp program that handles the speech. And the action is provided by the dropdown box action, you can customize a lot of action types to meet the needs of different chat friends. The speakers are also selected by the Drop-down box Whoto, which lists the names of all users in the current chat room. How to judge a new user into the chat room and exit the processing, here is not to say. Because the construction of a complete chat room to do a lot of work. Finally, a says text box provides the speech content.
With these several main chat elements. We will be able to address the speech.
Please take a look at the following program fragment
' Get the words and filter the script statements
Usersays=request.form ("says")
If InStr (Usersays, "<script") >0 Then
Usersays= ""
End If
' To judge whether there is a conversation or not to deal with it
If Len (usersays) <>0 Then
Session ("Whoto") =request.form ("Whoto")
Session ("Action") =request.form ("action")
If InStr (USERSAYS,CHR) >0 Then
Usersays=replace (USERSAYS,CHR), "\" &CHR (39))
End If
If InStr (USERSAYS,CHR) >0 Then
Usersays=replace (USERSAYS,CHR), "\" &CHR (34))
End If
Application.Lock
' Define a conversation buffer, and the following will give you a detailed analysis
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
' Not a whisper, add a
If Request.Form ("action") <> "Whisper" then
Application ("Counter") =application ("Zj_1counter") +1
Counter=application ("Zj_1counter")
' User's action handling
Select Case Request. FORM ("Action")
Case "Talk"
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> and <font color= #00bb00 >" &request. FORM ("Whoto") & "</font> said </i>:<font color= #0000aa >" &usersays& "</font><br ><BR> "
End If
Case "Shout"
Chats (counter) = "<font color=blue>" &usertime& "</font> <font color=black>" &username & "</font> <I> Chong <font color= #00bb00 >" &request. FORM ("Whoto") & "</font> shout </i>:<b><font color= #0000aa >" &usersays& "</font ></B><BR><BR> "
Case "kiss."
Chats (counter) = "<font color=blue>" &usertime& "</font> <font color=black>" &username & "</font> <I> Pro Pro <font color= #00bb00 >" &request. FORM ("Whoto") & "</font> cheek </i>:<font color= #0000aa >" &usersays& "</font><br ><BR> "
Case "hug."
Chats (counter) = "<font color=blue>" &usertime& "</font> <font color=black>" &username & "</font> <I> gently holding the <font color= #00bb00 >" &request. FORM ("Whoto") & "</font></i>:<font color= #0000aa >" &usersays& "</font><br ><BR> "
Case "rage."
Chats (counter) = "<font color=blue>" &usertime& "</font> <font color=black>" &username & "</font> <I> toward <font color= #00bb00 >" &request. FORM ("Whoto") & "</font> Hengmeilengdui vertical </i>:<font color= #0000aa