We are building a chat application and are currently working on a system to see all the users in a given room.
We have a Mongo Document set up with an array of active_users
where we will push
and pull
user names to in order to keep track of the online users. We have come to the conclusion that realizing a user has connected to a given room is fairly simple. All we need to do is in the router, when a user accesses the page, we push
that user's name into the document.
Now the tricky part is realizing when that user has left that given page? Obviously jQuery isn't a reliable option, so how do we know when a user's connection to a specific page is broken?