Chat room to achieve private chat (d)

Source: Internet
Author: User
Tags expression log
Chat room I have done a more complex chat room, almost have a BBS chat room all the functions, but because it is done with application, so more waste of resources. I think it's more reliable and simpler to use a database.
You can set up such a database chat, which is structured as follows:

Field Name Type length Note
1. Object CHAR 10 manipulating objects, all or someone
2. MSG CHAR 250 Message Content
3. Time DATETIME Sent
4. SENDER CHAR 10 Sender
5. ROOM CHAR 10 room name, the room where the sender is

In general, object is all, and you can specify someone when you need to whisper.
When the content is displayed, it is OK to simply "select * from chat where object= ' all ' or object= '" & Session ("UserID") & "". Session ("User ID") is the authentication of the current user.
So, every user sees the chat content is "should" see. If with other data tables, such as Room,user, you can also complete such as stealth, kicking people, open rooms, close rooms, hidden rooms and other functions, if you add an expression profile emote. TXT will be able to do the expression action. Of course, doing so requires an interpreter to send the message to determine what command the user entered and modify the datasheet accordingly.

Roking:roking@21cn.com

First of all, the overall idea: the use of application objects to save all the chat public information, such as visitor ID, room status, public chat information, and for everyone to use senssion objects to save and personal information, such as: expression, color, talk target ID.
The user's display area takes public chat information from the Application object and displays it in conjunction with private chat ....


Nikl:nikl@163.net

"Whispering" only need to use application and session two built-in objects can be easily implemented as follows, I hope to help!

Set up a separate application & Session object for the user when they log in. For example, there are three users Nikl hero Viki use ASP's request to obtain three user names and deposit a variable (such as name) and initialize the session and application when they log on:
Session ("Uname") =name
Application (WHO) = ""
Whisper information exists in variable say, the conversation object exists in WHO. For example:
Nikl to Viki: Have you eaten?
The server side executes the code, after the conditional judgment executes whispers the incoming operation, the conversation content "Have you eaten?" "And the Conversation object" Viki "and assigns to the variable say and who; information (Have you eaten?) In application ("Viki") (Code: Application (WHO) =say), the destination client can only refresh the application (session "Uname") variable to see the information, the end of the program.
Please note:
The <%=application (Session ("name")) at the Viki end%> is actually <%=application (Viki))%> (Session ("Viki") is defined as "at Uname Login" Viki "And there is a browser) Thus, when the information content box is refreshed, the session (" Uname ") will be replaced by" Viki ", Viki can see the whisper message sent by Nikl, and Hero End <%=application (" Uname ")%> is actually <%=application (Hero)%> this variable is empty and hero can not see the information Nikl sends to Viki. So cleverly completed a whisper of the transmission.



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.