PHP school chat room handling abnormal offline method _ PHP Tutorial

Source: Internet
Author: User
PHP school chat room handling abnormal offline methods. Some netizens cannot leave the chat room through normal channels due to line disconnection or crashes, leading to abnormal display of online users! The solution is generally to set up the number of online users. some netizens cannot leave the chat room through normal channels due to line disconnection or crashes. as a result, the number of online users cannot be displayed normally! The solution is generally
  
1. create the number of online users file, which stores the id/pass/time of the online users. time indicates the last update time.
  
2. when the chat program runs normally, update its id/pass/time to notify the system that it is online at intervals of 1-2 minutes.
  
3. the system scans the online person list for a certain period of time, finds the IDs that have not been updated after the specified time (for example, 5 minutes), and confirms that they are offline.
  
4. the number of online users is the number of lines in the file, and the list is the row data.
  
I now use this method to download a chat room!
  
This method is relatively simple, but file sharing is critical when many people are involved. through practice, I found that a method that consumes a very small amount of system resources can solve the sharing problem!
  
   The specific ideas are as follows:
1. create a useronline subdirectory to store online staff data
  
2. each entry creates a file named after the user name. The content is blank!
  
3. when the chat program runs normally, the files in its subdirectories are Updated at intervals.
  
4. the system determines whether the number of users is offline based on the file update time in the directory.
  
5. the number of online users is the number of files in the directory. the list is the file name.
  
Advantage: each person updates his/her own files and does not affect others. there is no sharing problem!
  
It can be scanned every 5 minutes, so it consumes very little resources!
  
This technology will be used in my new chat room !!!

The reason for renewal is that you cannot leave the chat room through normal channels, resulting in abnormal display of the number of online users! The solution is generally to set up 1 online users...

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.