Php+mysql Chat Room Technology A brief talk on _php course

Source: Internet
Author: User
Tags clear screen

Recently, in Phpchina introduced the topic of PHP chat room technology, just I also recently in the project, also published a personal point of view.

Main functions of chat room:
1, registration, login, exit, data modification.
2, users request to create a chat room, custom chat room properties.
3, show chat room name, description, host, announcement, advertisement.
4, real-time display of online user list, can view online user information (nickname, Email,ip, online length, etc.).
5, post chat content, font properties, actions, expressions, common phrases.
6, allow stealth, private chat, scroll screen, screen users, clear screen, chat scene selection, background music, send the way to customize.
7, the administrator has the right to manage members (kick out, prohibit speech, transfer administrative authority).


Precautions:
1, taboo use frame structure (IFRAME does not bring any benefit except to relieve your labor)
2, the foreground and background code is completely separated, only through the AJAX channel to transmit data, and should only transmit the necessary data. (Foreground display data, background processing data)
3, taboo due to the entire page refresh caused by the program, only update the content needed to change (taboo use Header,meta refresh page).
4, when submitting the chat content, cannot blindly pursue the user experience the speed, but ignores the actual chat record submission order. (That is, the submitted chat record should be in the actual order of the server reorganization, and then transferred to the client, because there may be many people to submit information at the same time)


The technology used:
1, the bridge between the front and rear--ajax. can choose Jquery,xajax. I tend to jquery, fast, simple and durable, there are many plugins, updates are also fast.
2, the form of the data carrier--xml. In fact, the general chat room data is not very complex, with JSON completely enough.
3, Database abstraction layer--adodb. Use PDO a little faster. Individuals have become accustomed to using ADODB.
4, the data underlying storage media--mysql. There is no doubt about it.
5, Data intermediate storage medium--memcache. Stores high-speed read-write data into memcache shared memory, reducing the load on the database.
6, if you want to implement video and voice, requires the support of the service-side FMS (Flash Media Server), the client needs to install Flash Player. And it involves the interaction of data between the Html,javascript,flash and the background. There is not much information in this regard.


These are the most core technologies, and in practical application development, there are many details that need to be addressed.

For example: How to deal with the update of the online list?
There are two ways of doing this:
1, refresh the entire list, whether or not it has an update.
2, add new online members, delete the dropped members, change the data has changed members.
The second is obviously the best choice.

How to deal with xmlhttprequest concurrency problem?
JavaScript is single-threaded, and if there are two XMLHttpRequest objects at the same time, it is very easy to create problems, which requires us to control the generation and end of XMLHttpRequest.
In the chat room, we need to update the data mainly include: Online list (including member information updates), chat history, chat room properties and so on. And the frequency of these updates is inconsistent (if the time is consistent, only need to establish a xmlhttprequest can be disposed of). Chat history needs to be updated in a short time, and the online list can be updated a little longer. Without the use of frames, if you set up XMLHttpRequest objects separately, concurrency problems are likely to occur. This requires creating a control function for the time and process.
SetInterval (Process_control (), 3000)//three seconds call
function Process_control in the implementation of task scheduling, such as: a certain time interval to perform the task, when the task is completed before the next task.

http://www.bkjia.com/PHPjc/486644.html www.bkjia.com true http://www.bkjia.com/PHPjc/486644.html techarticle recently, in Phpchina introduced the topic of PHP chat room technology, just I also recently in the project, also published a personal point of view. Chat Room main functions: 1, registration, login ...

  • 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.