How to implement Comet ?

前端 未结 1 749
离开以前
离开以前 2020-12-17 05:45

I have been developing web applications for some time but have very recently been introduced with the Comet server side push technology and my understanding of this technolo

相关标签:
1条回答
  • 2020-12-17 06:03

    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.

    This solution is one of the factors that has resulted in the concencus that PHP and Comet/WebSockets don't scale. See:

    • solution for COMET and PHP
    • Using comet with PHP?

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

    The advantages are that these solution were built with the idea of handling multiple concurrent connections in mind. They also provide libraries which offer additional functionality such as pub/sub which you are likely to want and therefore have to implement yourself. I worked for Caplin Systems who built the Liberator product and it's a highly tuned software solutions built entirely to handle and solve this solution.

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

    Answer taken from 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
    • Migratory: http://migratory.ro/migratory-push-server.html
    • 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.

    I'd recommend that you don't try and implement a solution for Comet/WebSockets from scratch. It's a very well understood problem with a number of excellent solutions. And the solution still isn't simple to implement from scratch. The interesting problem you'll need to solve is one of state synchronisation across multiple clients so the great thing about these existing realtime technologies is that you can use them and concentrate on building your app.

    Possibly also of interest:

    • XMPP BOSH v Comet
    • Realtime Web Technologies Guide
    0 讨论(0)
提交回复
热议问题