mardi 3 octobre 2017

Accounting for users that have left website without using onunload

I have a webservice with very limited resources (I will be able to handle about 3 simultaneous users).

When users interact with my website they start a complex process server-side. (This process is the limiting factor, as my server machine will not be able to handle many in parallel, and clients cannot run this on their side.)

My question is how to make sure to end the process for users that leave, for example by closing the window.

I have considered onunload and onbeforeunload, but they are also triggered by links within the website (which I need for users to be able to interact with the process) so that does not seem like an option.

This approach seems problematic according to other questions (see this, for example), but it could work if there were a way to check if the user is still an active user when performing the action triggered by onunload (even if in a different page of the website), but I don't know how to do this.

I have also considered periodically checking the list of active users and cancelling the process for users that have left, but I don't know if this is even possible.

I have zero experience with cookies, but could this be a place to use them? Can the server access the (still living) cookies of disconnected users?

Which sounds like a reasonable approach for this problem?

Aucun commentaire:

Enregistrer un commentaire