問題:
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參考二: How do I implement basic “Long Polling”?