Chat room to achieve private chat 1th/4 page _ Application Tips

Source: Internet
Author: User
Tags chr
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), "\" &AMP;CHR (39))
End If
If InStr (USERSAYS,CHR) >0 Then
Usersays=replace (USERSAYS,CHR), "\" &AMP;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 >" &usersays& "</font>< Br><br> "
Case "Nudge"
Chats (counter) = "<font color=blue>" &usertime& "</font> <font color=black>" &username & "</font> <I> gently push push <font color= #00bb00 >" &request. FORM ("Whoto") & "</font> arm </i>:<font color= #0000aa >" &usersays& "</font><br ><BR> "
Case "giggle."
Chats (counter) = "<font color=blue>" &usertime& "</font> <font color=black>" &username & "</font> <I> silly toward <font color= #00bb00 >" &request. FORM ("Whoto") & "</font> smile </i>:<font color= #0000aa >" &usersays& "</font><br ><BR> "
Case "punching."
Chats (counter) = "<font color=blue>" &usertime& "</font> <font color=black>" &username & "</font> <I> alignment <font color= #00bb00 >" &request. FORM ("Whoto") & "</font> is a fist </i>:<font color= #0000aa >" &usersays& "</font>< Br><br> "
Case "foot kick"
Chats (counter) = "<font color=blue>" &usertime& "</font> <font color=black>" &username & "</font> <I> volley kick in <font color= #00bb00 >" &request. FORM ("Whoto") & </font> head </i>:<font color= #0000aa > "&usersays&" </font><br ><BR> "
Case "confession."
Chats (counter) = "<font color=blue>" &usertime& "</font> <font color=black>" &username & "</font> <I> pulls <font color= #00bb00 >" &request. FORM ("Whoto") & </font> hand tone Heart Long said </i>:<font color= #0000aa > "&usersays&" </font> <BR><BR> "
Case "Slap"
Chats (counter) = "<font color=blue>" &usertime& "</font> <font color=black>" &username & "</font> <I> mercilessly slapped the <font color= #00bb00 >" &request. FORM ("Whoto") & "</font> several slaps </i>:<font color= #0000aa >" &usersays& "</font>< Br><br> "
Case "Bow"
Chats (counter) = "<font color=blue>" &usertime& "</font> <font color=black>" &username & "</font> <I> respectfully to <font color= #00bb00 >" &request. FORM ("Whoto") & "</font> stooping to bow </i>:<font color= #0000aa >" &usersays& "</font>< Br><br> "
case, "sorry."
Chats (counter) = "<font color=blue>" &usertime& "</font> <font color=black>" &username & "</font> <I> feel Shipi apology, whispered to <font color= #00bb00 >" &request. FORM ("Whoto") & "</font> said </i>:<font color= #0000aa >" &usersays& "</font><br ><BR> "
Case "surprise."
Chats (counter) = "<font color=blue>" &usertime& "</font> <font color=black>" &username & "</font> <I> surprise on <font color= #00bb00 >" &request. FORM ("Whoto") & "</font> spit out the tongue </i>:<font color= #0000aa >" &usersays& "</font>< Br><br> "
Case "Yawn"
Chats (counter) = "<font color=blue>" &usertime& "</font> <font color=black>" &username & "</font> <I> <font color= #00bb00 >" &request. FORM ("Whoto") & "</font> wide open mouth, yawned </i>:<font color= #0000aa >" &usersays& "</font ><BR><BR> "
Case "Smile"
Chats (counter) = "<font color=blue>" &usertime& "</font> <font color=black>" &username & "</font> <I> <font color= #00bb00 >" &request. FORM ("Whoto") & "</font> slight smile </i>:<font color= #0000aa >" &usersays& "</font>< Br><br> "
Case "shake hands."
Chats (counter) = "<font color=blue>" &usertime& "</font> <font color=black>" &username & "</font> <I> tightly hold <font color= #00bb00 >" &request. FORM ("Whoto") & "</font> hand </i>:<font color= #0000aa >" &usersays& "</font><br ><BR> "
Case "shrug."
Chats (counter) = "<font color=blue>" &usertime& "</font> <font color=black>" &username & "</font> <I> to <font color= #00bb00 >" &request. FORM ("Whoto") & "</font> shrugged shoulders </i>:<font color= #0000aa >" &usersays& "</font>< Br><br> "
Case "Comfort"
Chats (counter) = "<font color=blue>" &usertime& "</font> <font color=black>" &username & "</font> <I> Pat <font color= #00bb00 >" &request. FORM ("Whoto") & "</font> shoulder, eyes concern said </i>:<font color= #0000aa >" &usersays& "</font ><BR><BR> "
Case "angry"
Chats (counter) = "<font color=blue>" &usertime& "</font> <font color=black>" &username & "</font> <I> gas Drum's toot mouth on <font color= #00bb00 >" &request. FORM ("Whoto") & "</font> road </i>:<font color= #0000aa >" &usersays& "</font><br ><BR> "
Case "crying."
Chats (counter) = "<font color=blue>" &usertime& "</font> <font color=black>" &username & "</font> <I> can't help <font color= #00bb00 >" &request. FORM ("Whoto") & "</font> burst into tears </i>:<font color= #0000aa >" &usersays& "</font>< Br><br> "
Case "sobbing."
Chats (counter) = "<font color=blue>" &usertime& "</font> <font color=black>" &username & "</font> <I> hands covering his face, <font color= #00bb00 >" &request. FORM ("Whoto") & "</font> purring </i>:<font color= #0000aa >" &usersays& "</font>< Br><br> "
Case "commitment"
Chats (counter) = "<font color=blue>" &usertime& "</font> <font color=black>" &username & "</font> <I> to <font color= #00bb00 >" &request. FORM ("Whoto") & </font> </i>:<font color= #0000aa > "&usersays&" </font> <BR><BR> "
Case "Not shed"
Chats (counter) = "<font color=blue>" &usertime& "</font> <font color=black>" &username & "</font> <I> reluctantly pulled <font color= #00bb00 >" &request. FORM ("Whoto") & "</font> </i>:<font color= #0000aa >" &usersays& "</font><br ><BR> "
Case "Affectionate"
Chats (counter) = "<font color=blue>" &usertime& "</font> <font color=black>" &username & "</font> <I> with affectionate eyes, looking at <font color= #00bb00 >" &request. FORM ("Whoto") & "</font></i>:<font color= #0000aa >" &usersays& "</font><br ><BR> "
Case "confusing"
Chats (counter) = "<font color=blue>" &usertime& "</font> <font color=black>" &username & "</font> <I> grasping scalp looking at <font color= #00bb00 >" &request. FORM ("Whoto") & "</font> revealing a puzzled look </i>:<font color= #0000aa >" &usersays& "</font> <BR><BR> "
Case "puzzled"
Chats (counter) = "<font color=blue>" &usertime& "</font> <font color=black>" &username & "</font> <I> look at the <font color= #00bb00 >" &request in an unpredictable way. FORM ("Whoto") & "</font></i>:<font color= #0000aa >" &usersays& "</font><br ><BR> "
Case "Disaster"
Chats (counter) = "<font color=blue>" &usertime& "</font> <font color=black>" &username & "</font> <I> gloat over <font color= #00bb00 >" &request. FORM ("Whoto") & "</font> said </i>:<font color= #0000aa >" &usersays& "</font><br ><BR> "
Case "laughing."
Chats (counter) = "<font color=blue>" &usertime& "</font> <font color=black>" &username & "</font> <I> to <font color= #00bb00 >" &request. FORM ("Whoto") & "</font> laughing </i>:<font color= #0000aa >" &usersays& "</font>< Br><br> "
Case "Frown"
Chats (counter) = "<font color=blue>" &usertime& "</font> <font color=black>" &username & "</font> <I> frowned on <font color= #00bb00 >" &request. FORM ("Whoto") & "</font></i>:<font color= #0000aa >" &usersays& "</font><br ><BR> "
Case "Grievance"
Chats (counter) = "<font color=blue>" &usertime& "</font> <font color=black>" &username & "</font> <I> very wronged to look at <font color= #00bb00 >" &request. FORM ("Whoto") & </font> tears streaming down </i>:<font color= #0000aa > "&usersays&" </font> <BR><BR> "
Case "Happy"
Chats (counter) = "<font color=blue>" &usertime& "</font> <font color=black>" &username & "</font> <I> cheerfully to <font color= #00bb00 >" &request. FORM ("Whoto") & "</font> said </i>:<font color= #0000aa >" &usersays& "</font><br ><BR> "
Case "depression."
Chats (counter) = "<font color=blue>" &usertime& "</font> <font color=black>" &username & "</font> <I> full face gloomily on <font color= #00bb00 >" &request. FORM ("Whoto") & "</font> said </i>:<font color= #0000aa >" &usersays& "</font><br ><BR> "
Case "disappointment."
Chats (counter) = "<font color=blue>" &usertime& "</font> <font color=black>" &username & "</font> <I> crestfallen to <font color= #00bb00 >" &request. FORM ("Whoto") & "</font> said </i>:<font color= #0000aa >" &usersays& "</font><br ><BR> "
Case "nerves."
Chats (counter) = "<font color=blue>" &usertime& "</font> <font color=black>" &username & "</font> <I> nerves <font color= #00bb00 >" &request. FORM ("Whoto") & "</font> said </i>:<font color= #0000aa >" &usersays& "</font><br ><BR> "
Case "Mystery"
Chats (counter) = "<font color=blue>" &usertime& "</font> <font color=black>" &username & "</font> <I> very mysteriously to <font color= #00bb00 >" &request. FORM ("Whoto") & "</font> said </i>:<font color= #0000aa >" &usersays& "</font><br ><BR> "
Case "Spoiled"
Chats (counter) = "<font color=blue>" &usertime& "</font> <font color=black>" &username & "</font> <I> pulls <font color= #00bb00 >" &request. FORM ("Whoto") & "</font> hand spoiled </i>:<font color= #0000aa >" &usersays& "</font><br ><BR> "
Case "Grimace"
Chats (counter) = "<font color=blue>" &usertime& "</font> <font color=black>" &username & "</font> <I> to <font color= #00bb00 >" &request. FORM ("Whoto") & </font> made a grimace </i>:<font color= #0000aa > "&usersays&" </font>< Br><br> "
Case "Helpless"
Chats (counter) = "<font color=blue>" &usertime& "</font> <font color=black>" &username & "</font> <I> to <font color= #00bb00 >" &request. FORM ("Whoto") & "</font> very reluctantly </i>:<font color= #0000aa >" &usersays& "</font>< Br><br> "
End Select

' is a whisper
Else

' Whisper handle
Application ("chat") = "<font color=blue>" &usertime& "</font> <font color=black>" & username& "</font> <I> quietly to <font color= #00bb00 >" &request. FORM ("Whoto") & "</font> whisper </i>:<font color= #0000aa >" &usersays& "</font><br ><BR> "
' To who say
Application ("Chatto") =request. FORM ("Whoto")
' The man who Speaks
Application ("owner") =username
Session ("chat") = "true"
End If


' Talk Global
Application ("Chats") =chats


Application.UnLock


End If

The above program is the user's Speech and action and speech object generated HTML statements and save. To be shown in the chat room behind it, please note that the whisper is stored in the Global Application Object application ("Chat"). OK, the next section is to give you a detailed analysis of the content of the speech is how to deal with.
Current 1/4 page 1234 Next read the full text

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.