AJAX Server Push

2019-05-30 17:02发布

问题:

Well, I have doubts about this technology, more precisely in its implementation, can not find good examples on the Internet, as it involves javascript and php, only, you would have some links where I can find this stuff really works and that ?

回答1:

A great source for all things Comet is Comet Daily. Unfortunately it's not updated all that often any more but there are some fantastic old articles in there. It's contributed to by guys that have been developing Comet solutions for over 10 years.

Comet seems to get incorrectly bundled as meaning just one particular connection mechanism is used, but it's actually a paradigm for realtime push from server to client. Comet servers can use HTTP Streaming, HTTP Long-Polling, classic polling and WebSockets.

If you are interested in the latest Push Technology then you should take a look at WebSockets which is a standardised approach to not only server to client push, but also bi-directional realtime communication between servers and clients (web browsers and other clients).

Some current trending push technologies are:

  • socket.io
  • Hosted WebSockets services such as Pusher - who I work for
  • Faye for self hosted Ruby or Node dev
  • SignalR for IIS and .NET
  • There are many more and more information on realtime web technologies can be found on this guide.

If you want to use PHP you could struggle to build an application using realtime Push which will scale above a small number of connections. Have a read through this question on concurrency - How to implement event listening in PHP for more information.



回答2:

Do you specifically mean Ajax push? Because a more common method is comet push, I has been a while I worked with this, probably more browsers support this.

A good implementation can be found here: http://www.ape-project.org/

Well it's called Ajax Push engine, so I suppose that is what you are looking for.



回答3:

If you work with Java/Scala/Ruby/Groovy, take a look at Atmosphere, which is being actively developed/used (I'm the creator). There are many samples available.



回答4:

Check out the Bayeux Protocol and CometD implementation in Java & Javascript.

From http://cometd.org/ : CometD is a scalable HTTP-based event routing bus that uses a Ajax Push technology pattern known as Comet.

Here the link to an interesting article describing the technologies involved and a comparison of CometD and Atmosphere implementations.