PHP Classroom Chat Room handling abnormal offline methods

Source: Internet
Author: User
Keywords PHP Classroom Chat Room handling abnormal offline methods

Some netizens due to line drop, the crash and other reasons, can not pass the normal way to leave the chat room, resulting in online numbers can not be displayed properly! The workaround is generally
  
1 Set up the online people file, which saves the online person's id/pass/time where time is last updated
  
2 Chat program normally run every time to update their id/pass/time notification system themselves online, generally can be 1-2 minutes
  
3 The system scans the online list for a period of time, looking for those IDs that have exceeded the specified time (e.g. 5 minutes) without updating, confirming that they have been abnormally offline
  
4 people online is the number of lines in the file, the list is row data
  
My current offer to download the chat room is implemented in this way!
  
This method of process is relatively simple, but in the people of the file sharing problem becomes the key, I through the practice, found a consumption system resources very little, can be a good solution to the sharing Method!
  
   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 as the filename. Content is empty!
  
3 When the chat program is running, update the files in your subdirectory at regular intervals
  
4 system According to the file update time in the directory to determine whether the number of users offline
  
5 online number of files in the directory, list of file names
  
Pros: Everyone updates their files, does not affect other people, there is no sharing problem!
  
Because it can be scanned every 5 minutes, so little consumption of resources!
  
This technology will be used in my new chat room!!!
  
  • 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.