Home > Backend Development > PHP Tutorial > Chat Room Technology-Methods to Handle Abnormal Offline_PHP Tutorial

Chat Room Technology-Methods to Handle Abnormal Offline_PHP Tutorial

WBOY
Release: 2016-07-20 11:03:40
Original
842 people have browsed it

Some netizens are unable to leave the chat room through normal channels due to line disconnection, crashes, etc., causing the number of people online not to be displayed normally! The solution is generally
1. Create a file of the number of people online, and save the id/pass/time of the online people in it. Time is the last update time.
2. Update your id/pass at regular intervals when the chat program is running normally. /time notifies the system that it is online, usually 1-2 minutes
3. The system scans the list of online people every grid for a period of time, looking for those IDs that have not been updated for more than the specified time (such as 5 minutes), and confirm that they 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!
The process of this method is relatively simple, but the problem 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 and file name in it. 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 file in the directory Number, 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!

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445269.htmlTechArticleSome netizens are unable to leave the chat room through normal channels due to line disconnections, crashes, etc., resulting in a loss of the number of people online Display normally! The solution is generally 1. Create an online number file...
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