简体   繁体   English

如何在“流星”应用程序中添加“在线用户数”功能?

[英]How to add a “# users online” feature to Meteor app?

I'm working on a Meteor app and I want to add a feature that would say how many people are on the website at a time, similar to omegle.com where it says "38,000+ online now" or whatever. 我正在开发Meteor应用,我想添加一个功能来说明一次网站上有多少人,类似于omegle.com上说“现在在线超过38,000”或类似内容。 Is this possible with Meteor? 流星有可能吗? If it is, I have no idea how to execute it, and that's why I'm asking it here. 如果是这样,我不知道如何执行它,这就是为什么我在这里问它。 Does anybody know how to do this? 有人知道怎么做这个吗?

You can use presence package for that purpose, see https://atmospherejs.com/package/presence . 您可以为此目的使用presence包,请参阅https://atmospherejs.com/package/presence It provides the live data on the user state. 它提供有关用户状态的实时数据。 For example, the easiest way to get the number of online users is: 例如,获得在线用户数量的最简单方法是:

Presences.find({online: true}).count();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM