質問

i want to get my web application users logged list with all possible flows like unexpected shutdown (power cut), force closed browser and something whatever in this flow. i want to only show online users with some status text. i find some solutions but,they are solutions will take server lot of memory like update the login table to last_logged column with current time every 20 seconds from client side to server side and check last_logged time less than 20 seconds from now it takes status as offline. i need perfect solution with out heavy work load to server. simply, i want to like this gmail chat list all flows working fine on gmail chat. i don't know about these concept i am new this concept. may be your already find this solution if you already know this solution for this type of concept please share your knowledge. it, will must helpful to all developers and i am appreciate your effect.

Thanks for spending your valuable time for reading my post :)

役に立ちましたか?

解決

Why do you think updating a table takes "a lot of memory"? or why do you think its "heavy work load to server"? Its basically nothing. There is no solution other than using a database as you described, because browsers don't implement any kind of messages for when a user leaves your site. You've got to track this yourself by updating a table with last access time and so on.

And even if browsers did implement "user has left your site" type messages, you would still have to update a database and read from one to track this stuff.

Plus, even if browsers sent these kinds of message, if the user lost power, the browser would obviously not be able to send it.

他のヒント

I am interested to know what solution you settled with. I am also faced with the same challenge as you and I have decided to use Memcached server to accomplish this. Basically what I am doing is caching a key which is the customer id in Memcached for a duration and everytime a user does any activity which signifies his online presence, I update the expiry time to say something like 1 min. If no new event or action is created by the user, then the key expires from the database and he goes offline to the other users. Just the same thing you described but am only doing it in memory.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top