Keep track of clients currently on a page

Viewed 270

I would like to keep track of all clients currently on a page in my app. I am basically implementing something similar to live user list on Google Doc.

enter image description here

A naive approach would be to send a heartbeat to the server at an interval, when a client is on the page.

As an alternative, I am thinking about implementing the following:

  1. Once a client connects, push the userId to an array in the db
  2. Observe the DDP connection with the connection ID
  3. Pull the userId when the DDP connection is closed

But I don't know if that is even feasible. Any ideas or a suggestion for a better solution?

Edit

I would like to only track status of users on a certain page. Therefore meteor-user-status won't suit my needs.

Also I want to track anonymous clients (users who are not logged in)

1 Answers
Related