Rails 3: Real-time server push?

2019-04-07 19:48发布

问题:

I'm trying to write a Rails 3 application in which a server can push data to multiple clients in real time.

I've heard of Juggernaut, but I've also heard that it does not work with Rails 3. I tried APE (AJAX Push Engine), but I'm not having much luck with it.

I'm very new to Rails. I can't find many guides that involve real-time push, and Rails 3. I was looking for a free, easy (if possible) solution to this. If anyone could point me in the right direction, I'd greatly appreciate it.

回答1:

Check out Faye: http://faye.jcoglan.com/ - I hear really good things about it.

if you're looking for a hosted solution, i've used Pusher http://pusher.com/ in the past, and loved it. i converted a site that used ajax polling over to pusher in about 30 minutes.



回答2:

You can try juggernaut to do what you want.

The github repository : https://github.com/maccman/juggernaut Example of application with juggernaut : https://github.com/maccman/holla

Enjoy :)



回答3:

Have you looked into http://socket.io ? It powers the push functions behind Juggernaut, if I recall correctly.

There appears to be a library for Rails here: https://github.com/markjeee/Socket.IO-rack -- it says 2.3+, which I assume means 3 is ok (though I'm not a Ruby guy, so I wouldn't really know).



回答4:

In keeping with the Pusher suggestion, there's RMSN - a drop in replacement I've written using NowJS. https://github.com/leppert/RMSN



回答5:

Starting with Rails 4, you could also use Entangled:

https://github.com/so-entangled/rails

It basically keeps all data between client and server in sync in real time through web sockets. It's easy to set up, so give it a try.