Technical Essentials of "No refresh" in database chat room

Source: Internet
Author: User
Tags client
Chat Room | data | database | refresh | No refresh chat room is one of the most common applications of real-time network interaction. Chat room production to solve the following problems.
1. Who is speaking
2, tell who to listen to
3. What to say
Unlike ICQ, ICQ data streams are one-to-one relationships. Just fix the top three questions.
can be achieved.
Chat room because there are one-to-many, one or one-to-one multiple data relationships, so there is a
The problem of data storage.
ASP chat room's data storage generally has three kinds of forms: first, uses the global variable application and
The Session object. This form of fast effect is good, but the system resource consumption is too big. The second is the application of reading
Write the database implementation. This method is concise but the server frequently reads and writes data according to the database is very tired. The third type is available
Read and write TXT file complete. Suitable for simple chat rooms.
Three methods have a common feature: the client to get new chat data, must refresh
Call. Refresh time is too short, the screen shaking fierce, refresh time too long, waiting time too much sense speed
Too slow. So people use trigger refresh and automatic refresh to improve the feeling. Second, Lee
Use hidden frames to refresh and then add the content to the display frame, forming the so-called "no refresh" chat room, Solution
The problem of screen shaking was determined.
"No refresh" chat room the technical issues to be addressed are:
First, how to judge the new data
Second, the extraction of new data
Third, how to enable customers to break the new data can be updated in a timely manner
The above one or two is easy to implement with application, but the third problem is not easy to solve. With data
Library to do the chat room, the third question is relatively easy, but the first to second question to be a little bit of spirit. I use
Database do chat room with "No refresh" technology, no use of a application, mainly
The technical points are:
Set up a table with only one field in the Database, field name: BS
The value of BS each time the user logs in. Set a session as each specific user's
The current number of speeches, initially for BS-1.
User every time to make BS + 1 (Session value does not add at this time, forming session and BS difference)
To determine on an implicit refresh frame:
If BS and session are bad, the read database reads the new data and displays it in the display frame.
Session+1 said the new data had been read and no longer stressed.
Repeat this process until all new data is read out and displayed. At this point BS = Session
The above method solves the problem of judging the new data and extracting the new data. Because the new data
There is no change in itself, is still stored in the database, the client no matter how much time difference, only
To own the session and BS have a bad, when reading library, how much more than how many records, to solve the client
The refresh variance does not show the problem.
The above method, of course, can also use application to set BS. and one but BS to a certain value
(See the number of speakers at the same time), reset to 1.
The above methods are in the IIS 4 platform, LAN, Internet access.

Southerly



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.