如何实施基本的“长轮询”?

流过昼夜 提交于 2020-08-14 01:15:06

问题:

I can find lots of information on how Long Polling works (For example, this , and this ), but no simple examples of how to implement this in code. 我可以找到很多关于Long Polling如何工作的信息(例如, 这个这个 ),但没有关于如何在代码中实现它的简单示例。

All I can find is cometd , which relies on the Dojo JS framework, and a fairly complex server system.. 我所能找到的只是依赖于Dojo JS框架的cometd ,以及一个相当复杂的服务器系统。

Basically, how would I use Apache to serve the requests, and how would I write a simple script (say, in PHP) which would "long-poll" the server for new messages? 基本上,我将如何使用Apache来处理请求,以及如何编写一个简单的脚本(例如,在PHP中),它将“长时间轮询”服务器以获取新消息?

The example doesn't have to be scaleable, secure or complete, it just needs to work! 该示例不必是可扩展的,安全的或完整的,它只需要工作!


解决方案:

参考一: https://stackoom.com/question/1Ong/如何实施基本的-长轮询
参考二: https://oldbug.net/q/1Ong/How-do-I-implement-basic-Long-Polling
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!