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...