How can I display a list of all LOGGED IN users with Meteor.js

后端 未结 1 957
悲&欢浪女
悲&欢浪女 2021-01-22 07:05

I have been trying for days to get a list of logged in users in a Meteor chat app. I tried many different things. I managed to add a login flag on the user profile object. Serve

相关标签:
1条回答
  • 2021-01-22 07:38

    To change the users profile.login property you need to do Meteor.users.update(..) or call a server method that does that. Just changing the user object's property will not work.

    Generally I would recommend to not persist the users state into the mondodb database but hold it in a Collection in memory.

    The easiest might be to just use one of these packages:

    • https://github.com/dburles/meteor-presence/
    • https://github.com/mizzao/meteor-user-status

    or study their source code to see how to propagate the user status.

    0 讨论(0)
提交回复
热议问题