实时实时通知 Jquery PHP
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12979833/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
RealTime live notification Jquery PHP
提问by Nich
I'm tried to implementing a live notification which is like the facebook newsticker and the notifications(on top). I was wondering what's the good solution to archieve this. I implemented an chat application before which I fired AJAX GET request in certain time to archieve the realtime, but it seems not good. I checked facebook using firebug, there is no GET request fired(or it is hided?)
我试图实现一个实时通知,就像 facebook newsticker 和通知(在顶部)。我想知道什么是存档的好解决方案。我实现了一个聊天应用程序,在此之前我在特定时间触发了 AJAX GET 请求以存档实时,但似乎不太好。我使用 firebug 检查了 facebook,没有触发 GET 请求(或者它被隐藏了?)
Now here is my scenarion:
现在这是我的场景:
In main.php I have a live ticker and a notifications button.
在 main.php 中,我有一个实时自动收报机和一个通知按钮。
In bulletion.php and User.php When I perform an add user,it will go heading to the bulletin or user.php.
在bulletion.php 和User.php 中当我执行添加用户时,它将转到公告或user.php。
How can I get informed in main.php when bulletin.php,user.php successfully created in database?
在数据库中成功创建bulletin.php,user.php 后,如何在main.php 中获得通知?
I checked this question as well before I asked. notification system in PHP/jQueryRealtime and php?
在我问之前,我也检查了这个问题。 PHP/jQuery Realtime 和 php 中的通知系统?
I was wonder,what's is long poling Ajax and session-based notification.How it can be archieved? I know Node.js can be good in implementing realtime, can it combine with PHP? and memcached ?
我想知道,什么是长轮询 Ajax 和基于会话的通知。如何归档?我知道 Node.js 可以很好地实现实时性,它可以与 PHP 结合使用吗?和内存缓存?
Any can provide sources to refer or example might be good.Thank you.
任何可以提供参考或示例的来源都可能是好的。谢谢。
回答by hexist
As a side note, PHP isn't really the best language to use when it comes to push notifications, it's really built around typical get/response kinda flows.
附带说明一下,在推送通知方面,PHP 并不是最好的语言,它实际上是围绕典型的获取/响应流构建的。
I use PHP for all my page stuff, but when it comes to push notifications of any sort I really like http://www.nodejs.org/and http://socket.io/to go with it. They're very easy to get setup, and will play well with you using php for the majority of your work, then using node to deal with push notification kinda stuff.
我对所有页面内容都使用 PHP,但是当涉及到任何类型的推送通知时,我真的很喜欢http://www.nodejs.org/和http://socket.io/使用它。它们很容易设置,并且可以很好地与您一起使用 php 完成您的大部分工作,然后使用 node 处理推送通知有点东西。
回答by Samuel Lubini
Have you thought about using HTML5 WebSockets? Have a look at EventSocketsand the kickstart project on Github.
你有没有想过使用 HTML5 WebSockets?在Github上查看EventSockets和 kickstart 项目。
回答by Matt S
I've had much success with the server-sent eventsstandard. It's very simple and works perfectly but it's only supported in modern browsers.
我在服务器发送事件标准方面取得了很大的成功。它非常简单且完美运行,但仅在现代浏览器中受支持。
回答by Luke
Meteoris a comet server using PHP and JavaScript to push data to browsers. It's very slick and worth a look, although it may be a little hard to setup/implement.
Meteor是一个彗星服务器,使用 PHP 和 JavaScript 将数据推送到浏览器。它非常漂亮,值得一看,尽管设置/实施可能有点困难。
Edit: Quick demo here
编辑:这里的快速演示

