简体   繁体   中英

how to change user availability status in mysql database and php chat application

I have a chat application in which the user can change his availability status (online / offline / busy).

On status_change event I want to update it to a MySQL database which can be visible to all online users.

Set field for last_activity_time with timestamp and everytime the user opens something or sends something update this field with the current timestamp

but generally note that MySQL isn't the best way to create a chat app it's somehow exhaustive and doesn't scale

and from your code,

Assume that user with no activity for let's say 5 minutes will be set to away and for 10 minutes will be set to offline,

If you use AJAX then set the user to update his status via AJAX, every let's say 1 minute and in this case you can easily identify offline from online users, ie users with time stamp difference more than 1.5 minutes will be considered offline.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM