如何實施基本的“長輪詢”? - How do I implement basic “Long Polling”?

問題:

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”?
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章