To execute Flex cleanup function when browser is closed by user

前端 未结 3 680
忘掉有多难
忘掉有多难 2021-01-14 08:01

I have a Flex client application. I need a clean up function to run in Flex when the user closes the browser. I found the following solution on the net, but it only works ha

3条回答
  •  爱一瞬间的悲伤
    2021-01-14 09:01

    You'll never be able to reliably detect the browser code 100% of the time. If you really need to run actions then the safest course of action is to have clients send "i'm still alive" messages to the server. The server needs to track time by client and when a client doesn't send a message within the specified amount of time (with some wiggle room), then run clean-up activities.

    The longer you make the time the better, it depends on how time-critical the clean-up is. If you can get away with waiting 5 minutes that's great, otherwise look at 1 minute or 30 seconds or whatever is required for your app.

提交回复
热议问题