一个Facebook的通知系统在php [英] A facebook-like-notification system in php
问题描述
如何设置一个类似Facebook的通知系统:
- 用户A向用户B写入消息
- 数据库上的侦听器将消息路由到用户B
- 在用户B界面上,消息立即出现
How can I put in place a facebook-like-notification system: - A userA writes a message to the userB - A listener on the database routes the message to the userB - On the userB interface, the message appears instantly
如何在php中执行此操作?
How can I do that in php?
非常多,
回复
推荐答案
使用PHP来轮询或尝试实现基于推送的解决方案,如果你将有任何可观的流量。会发生什么,最终所有的PHP进程被阻塞,然后你不能再提供Web请求。
I wouldn't advise using either polling or trying to implement a push based solution using PHP, if you are going to have any sizable traffic. What happens is that eventually all the PHP processes get blocked, and then you can't serve anymore web requests.
查看node.js,cometd或其他基于推送的解决方案。如果您需要简单的操作并需要快速启动和运行,我建议您 http://pusherapp.com/ 。他们有一个PHP客户端可用和超级简单的API。
Look into node.js, cometd or another push based solution. If you need something simple and need to get up and running quickly, I'd recommend http://pusherapp.com/. They have a PHP client available and super simple API.
这篇关于一个Facebook的通知系统在php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!