Simplest way to check if user is idle?

Basically, I am considering any method call (or publication) as signifying active-user status. My app has a high sub-rate (it’s very hard to move around without triggering subs for more fine-grained data).

I was gonna set ~ connections[this.connection.id] = Date.now() every time a method/pub is called.

Then, I can CRON job every minute to delete all connections which are not active within the past, say, 10 minutes.

Is there an easier way to do this?

still maybe there is better way to do this from client side, with unsubscribing them and showing modal. To close modal provide button which resubscribe them ?

Thanks, but I am not interested in mizzao’s package. It is very robust and contains functionality far beyond what I need.

I like your second proposal. I think that is the simplest and most scalable way to do it. Although, like with any client-side solution, a few bad apples will disable the feature and my attempts to prevent them from eating my server’s CPU will have been bypassed!

You can always do your method table update and cron stuff, just dont kill DDPs, but signal client to unsubscribe.
And if they disable informing popup somehow, they will kill they way to resub back to have working app without changing route or how u set it up…

Maybe you would like this package https://github.com/3stack-software/meteor-idle-watcher/