我开发 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:
- StreamHub: http://streamhub.blogspot.com/2010/12/html-5-web-sockets-arrives-in-streamhub.html
- APE ("Native WebSockets"): http://www.ape-project.org/
- Caplin Liberator: http://www.caplin.com/caplin_liberator.php
- MigratoryData: https://migratorydata.com/
- CometD: http://cometdproject.dojotoolkit.org/documentation/2.x/howtos/websocket
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/