Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Meteor: display list of current users for document

I have a list of documents in meteor that only authorised users can access. It's kind of like google docs. Is there an easy way to get a list of users which are currently viewing them?

I thought of including a "currentUsers" field in my mongodb object, and push/remove users whenever users view or stop viewing the component. This feels like a strange way to do it since data is persisted and is probably prone to errors since it doesn't exactly represent users currently viewing the component at a moment in time

This stackoverflow question is kind of what I'm looking for, but the answer is a little old, and I'm not sure how to go about using sockjs either. If someone can provide a working example that will be great.

Any help is greatly appreciated!

like image 460
Poh Zi How Avatar asked Feb 26 '17 04:02

Poh Zi How


1 Answers

There are several options:

DIY solution - storing data in Collection

package meteor-user-status https://github.com/mizzao/meteor-user-status

package mrt:spy (which seems to be deprecated, but maybe you can build on top of it) https://atmospherejs.com/mrt/spy

socket.io https://atmospherejs.com/joncursi/socket-io-client

like image 83
metalcamp Avatar answered Sep 29 '22 10:09

metalcamp