问题:
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
来源:oschina
链接:https://my.oschina.net/u/4432649/blog/4329362