简体   繁体   English

如何找出多少个使用长轮询方法的在线用户?

[英]how to find out how many online user with long polling method?

i need best way to find out how many people are online with long polling method. 我需要最好的方法来找出使用长轮询方法在线的人数。

why i need long polling method to acquire that? 为什么我需要使用长轮询方法来获取它?

i need to know how many person are online in my site.of course i can do this with some query and update it in my site by each page load but i think no way to use this method in chat room is there? 我需要知道站点中有多少人在线。当然我可以通过一些查询来做到这一点,并通过每次页面加载在站点中对其进行更新,但是我认为没有办法在聊天室中使用此方法吗?

`lastvisit` >= DATE_SUB(now(), INTERVAL 5 MINUTE)

any solution for this?if i can acquire that with no server polling i do appreciate if you guide me to right direction 任何解决方案?如果我能在不进行服务器轮询的情况下获得它,我会很感激您的正确指导。

If you're using long polling, then the number of users will be the number of active connectons to the poll handler - ie the total number of connections less those for other URLs - which is trivial to extract from the output of mod_status, however you omitted to tell us what server you are using. 如果您使用的是长时间轮询,则用户数将是轮询处理程序的活动连接数-即连接总数减去其他URL的连接数-从mod_status的输出中提取出来很简单,但是您省略告诉我们您使用的服务器。

However, if it were me, I'd simply use a database bound session handler and count the current sessions from there (but it's equally possible to do this using file or memory bound session handlers). 但是,如果是我,我将只使用数据库绑定的会话处理程序并从那里计数当前会话(但是也可以使用文件或内存绑定的会话处理程序来执行此操作)。

Since changes in the numbers are likely to be small relative to the number of requests coming in, this could be collected based on a scheduled job or by comparing a random number against a threshold rather than collected on every request. 由于数量变化相对于进入的请求数量可能很小,因此可以基于计划的作业或通过将随机数与阈值进行比较来收集,而不是针对每个请求进行收集。

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

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