How to implement Server push / long polling / comet using PHP and Javascript

假装没事ソ 提交于 2020-01-21 09:14:27

问题


How can I implement the comet / server push design pattern using PHP and Javascript? Essentially what I would like is something like this:

  • User clicks a 'submit' button
  • Javascript shows a message like 'Processing 0 / 100 items'
  • Whenever a new item is processed, the php / server pushes out an update, and the javascript changes the message to 'Processing 2/100 items, 3/100 items, and so on'.

How can I do this? Any links/info please?


回答1:


Comet with PHP has some tricky issues with scaling. An alternative would be a SaaS solution, such as WebSync On-Demand. (Disclaimer: I work there). That way you don't have to worry about any of the behind the scenes stuff, and you can just get your server-push functionality.




回答2:


There are a couple of very good examples at: How to implement comet with PHP




回答3:


Most of the services use the Client-initiated requests, but there's also Comet. There's a few articles out there on it.



来源:https://stackoverflow.com/questions/1829257/how-to-implement-server-push-long-polling-comet-using-php-and-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!