Methods for handling abnormal offline chat rooms in PHP Academy_PHP Tutorial

WBOY
Release: 2016-07-13 17:33:33
Original
760 people have browsed it


Some netizens are unable to leave the chat room through normal channels due to line disconnection, crashes, etc., resulting in the number of people online not being displayed properly! The solution is generally
 
 1 Create a file of the number of online people, which saves the id/pass/time of the online person, where time is the last update time
 
 2 Every once in a while when the chat program is running normally Update your id/pass/time to notify the system that you are online, usually 1-2 minutes
 
 3. The system scans the list of online people every grid for a period of time to find those who have exceeded the specified time (such as 5 minutes). The updated id is confirmed to have been abnormally offline
 
 4 The number of people online is the number of lines in the file, and the list is the line data
 
My chat room that is now available for download is implemented using this method !
 
This method has a relatively simple process, but the issue of file sharing becomes critical when there are many people. Through practice, I found a method that consumes very little system resources and can solve the problem of sharing very well!
 
 The specific ideas are as follows:
 1 Create a useronline subdirectory to store online personnel data
 
 2 Each person who enters creates a file with the user name in it named file. The content is empty!
 
 3 When the chat program is running normally, it updates the files in its subdirectory at regular intervals
 
 4 The system determines whether the number of users is offline based on the update time of the files in the directory
 
5 The number of people online is the number of files in the directory, and the list is the file name

Advantages: Everyone can update their own files without affecting other people, and there is no sharing problem!
 
Since it can be scanned every 5 minutes, it consumes very little resources!
 
This technology will be used in my new chat room! ! !

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/508607.htmlTechArticleSome netizens cannot leave the chat room through normal channels due to line disconnections, crashes, etc., resulting in a large number of people online Cannot display properly! The solution is generally 1 to create an online number of people...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template