【问题标题】:PHP : Best way to push data from server to clients.....?PHP:将数据从服务器推送到客户端的最佳方式.....?
【发布时间】:2011-08-10 20:29:05
【问题描述】:

在我的项目I need to push some data from server to the client 就像facebook 一样,当some updates are performed in the clients profile 就像有人在客户端的墙上写东西时,Facebook 会自动将其推送到客户端。

目前I am using AJAX 继续check the DB for the updates。那是not a good practice

我不想依赖客户端进行更新。我希望server should automatically push the data to the client side 在执行与客户端相关的一些更新时。

请建议一些网址或示例代码这样做......

提前谢谢.....

【问题讨论】:

  • 您正在寻找push techniques。有很多实现,看看什么对你有好处。

标签: php zend-framework client-server


【解决方案1】:

你可以使用node.js:http://nodejs.org/

【讨论】:

  • 你手头有一个推送示例的链接吗?
  • @hakre here you are
【解决方案2】:

您需要的是 comet/websocket 方法,我不知道任何 PHP comet 实现/框架,但是当您搜索它时,网络上有几个示例。

【讨论】:

    【解决方案3】:

    您应该看看 APE 项目,它支持多种与 Push 一样接近的变体,例如长轮询、XHRStreaming 和 WebSockets。

    编辑 仅在 PHP 中执行此操作并不是最佳选择,因为它会占用大量资源来保持所有这些连接处于活动状态。

    【讨论】:

      猜你喜欢
      • 2014-05-16
      • 1970-01-01
      • 2018-01-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-04
      • 1970-01-01
      • 2013-04-24
      相关资源
      最近更新 更多