Chat Room provides a file for each chat (the cache file) that records the time when the last message was sent. This saves users from updating unnecessarily. At the same time, the only way for Chat Room to recognize a user as on line is for the user to update.

If no messages have been sent for a long time, the first user to send a new message will appear to be the only user on line. The other users will then update, making it appear that they just joined the chat.

In order to prevent false "user has left the chat" messages, I modified the code to not generate these messages within the first five seconds after an update. This works if the update is caused by a user joining the chat, but not if the update is caused by a user sending a message. I don't understand why it's not working.

Comments

darren oh’s picture

Status: Active » Needs work
StatusFileSize
new8.25 KB

Here is the patch that isn't working.

darren oh’s picture

Title: Unable to delay removal of users » On-line users shown leaving
darren oh’s picture

Here's an updated patch to work with the cleaned-up code in the development version. I still haven't succeeded in delaying the "user has left" message.

darren oh’s picture

Until Drupal is fixed, you will need to apply the patch from issue 121876 to use this one.

darren oh’s picture

StatusFileSize
new12.08 KB

Patch was missing. I'm going to commit this because it makes the code easier to work with even though it doesn't solve the problem.

darren oh’s picture

Patch committed in CVS commit 57780.

darren oh’s picture

StatusFileSize
new1.54 KB

I've thought of a way to work around the problem. For each cache file (an empty file that exists to show the time of the last update) we store the old timestamp. If the current timestamp is less than five seconds old, we use the old timestamp to determine who's online. If the current timestamp is more than five seconds old, we use the new timestamp.

A rough draft of the idea is attached.

darren oh’s picture

Status: Needs work » Fixed

Fixed in CVS commit 58658.

Anonymous’s picture

Status: Fixed » Closed (fixed)