繁体   English   中英

PHP:将数据从服务器推送到客户端的最佳方式......?

[英]PHP : Best way to push data from server to clients…?

在我的项目中, I need to push some data from server to the clientfacebook一样I need to push some data from server to the client ,当some updates are performed in the clients profilesome 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端。

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

提前致谢.....

您应该看一下APE项目,该项目支持多种变体,这些变体尽可能接近Push,例如长轮询,XHRStreaming和WebSockets。

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

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM