ajax - 如何实现 cometd ?

标签 ajax websocket comet

我开发 Web 应用程序已经有一段时间了,但最近才接触到 Comet 服务器端推送技术,我对这项技术的理解还很不成熟。而链接http://www.zeitoun.net/articles/comet_and_php/start提供了两个在 PHP 中使用无限循环的简单示例实现,我想更多地了解上述方法的用途以及它是否适合生产。 Meteor(http://meteorserver.org/)、streamhub (http://www.stream-hub.com/)、freeliberator (http://www.freeliberator.com/index.php) 等专用 cometd 服务器有什么优势)?

Comet 服务器端推送与 HTML5 网络套接字设施有何不同?

我的主要目标是构建协作实时文档编辑工具的变体。

最佳答案

While the link http://www.zeitoun.net/articles/comet_and_php/start provides two simplistic example implementations using an infinite loop in PHP, I would like to know more on the repurcussions of the above methods and if it is suitable for production.

此解决方案是导致人们一致认为 PHP 和 Comet/WebSockets 无法扩展的因素之一。见:

What advantages do dedicated comet servers like Meteor(http://meteorserver.org/) , streamhub (http://www.stream-hub.com/), freeliberator (http://www.freeliberator.com/index.php) ?

优点是这些解决方案在构建时考虑到了处理多个并发连接的想法。他们还提供提供附加功能的库,例如 pub/sub您可能想要,因此必须自己实现。我曾在构建 Liberator 产品的 Caplin Systems 工作,它是一个高度调整的软件解决方案,完全用于处理和解决此解决方案。

Also how different is Comet server side push from HTML5 web socket facility ?

答案取自 here :

Comet is an umbrella term and there are many "Comet Servers" (see below) that use WebSockets as the transport mechanism when possible. Comet servers don't just use AJAX, XHR Long-Polling, Forever-Frame etc. They now use WebSockets and fallback to other transport mechanisms where required.

Here are just some of the "Comet Servers" that use WebSockets:

My principle objective is to build a variant of collaborative real time document editing facility.

我建议您不要尝试从头开始实现 Comet/WebSockets 的解决方案。这是一个非常容易理解的问题,有许多优秀的解决方案。而且该解决方案仍然不容易从头开始实现。您需要解决的有趣问题之一是跨多个客户端的状态同步,因此这些现有实时技术的好处在于您可以使用它们并专注于构建您的应用程序。

可能也有兴趣:

关于ajax - 如何实现 cometd ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8118828/

相关文章:

javascript - 重新创建 jQuery 的 ajaxStart 和 ajaxComplete 功能

javascript - socket.io中的socket变量是什么

ajax - 加载 cometd /服务器推送iframe时,停止浏览器 “throbber of doom”

javascript - 重新连接到服务器时如何强制 Atmosphere.js 使用首选传输?

javascript - 如何在第一次点击后禁用链接并允许用户仅在登录后投票

javascript - 向 Spring Controller 发送 JSON 时出现 406 错误

ajax - Paypal AJAX 组合

javascript - 为连接到 websocket 服务器的客户端生成唯一 ID

websocket - 在 Embedded Jetty 9 上的带注释的 @WebSocket 类中访问 HttpSession

ajax - 如何使用 ActionScript 3 进行 cometd 长轮询?