Chat room technology-how to handle abnormal off-line
Source: Internet
Author: User
Chat room Some netizens due to line off line, crash and other reasons, can not pass the normal way to leave the chat room, resulting in online numbers can not be normal display! The method of solving the problem is generally
1 Build online Number file, which saves the id/pass/time of the online person where time is the last update
2 Chat program in normal running time to update their own Id/pass/time notification system of their own online, generally can be 1-2 minutes
3 The system scans the online person for a period of time, looking for IDs that have exceeded the specified time (for example, 5 minutes) without updating, confirming that they are offline
4 online number of lines in the file, List of row data
I now provide the download of the chat room is implemented by this method!
This method process is relatively simple, but in a long file sharing problem becomes the key, I through practice, found a consumption system resources are very few, can be a good way to solve the shared!
The specific ideas are as follows:
1 Create a Useronline subdirectory to store online personnel data
2 Each entry person creates a file with a user name as the filename. Content is empty!
3 Chat program in normal operation, every once in a while to update the files in their subdirectories
4 system According to the directory file update time to determine whether the number of users offline
5 online number of files in the directory, list of file names
Advantages: Each person's update their own files, does not affect others, there is no sharing problem!
Because it can be scanned every 5 minutes, it consumes very little resources!
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.