[Solved] Keep track of clients currently on a page

I would like to keep track of all clients currently on a page in my app. I am basically implementing something similar to 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 and it is on that page, 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)

Hey @sungwoncho,

You may want to check mizzao:user-status package or socialize:user-presence.

Thanks for the link. I don’t think my needs are met with those packages. Please see my edit.

Solved. Please see http://stackoverflow.com/questions/36170372/keep-track-of-clients-currently-on-a-page