Ajaxmessaging rails gem - replacement? - ruby-on-rails

I found this gem:
http://code.google.com/p/ajaxmessaging/
Because this project is inactive I need something more fresh to do the same stuff, in my case, notification messaging to the client.
There is something similar and better than this? (for Passenger)

You want to look at Pusher (http://pusher.com), Faye (http://faye.jcoglan.com, http://asciicasts.com/episodes/260-messaging-with-faye), or Juggernaut (https://github.com/maccman/juggernaut). Pusher is probably easiest to get started with, but its a commercial product after a certain level of usage.

Related

Listen to Prosody Offline messages directory

I have developed a chat application using Prosody and I need to send a push notification when someone receives a message and isn't online.
This chat application works together with my WebApp written in Ruby on Rails.
I searched a lot and didn't found anything that sends push notifications from Prosody(I found for eJabberd but I had another problems with eJabberd). So I decided to look for a gem to RoR that monitors a directory, with that I can monitor the Prosody's offline message directory and get a callback when a message couldn't be delivered to a user and then send a push notification to him.
I found the gem Listen from guard(https://github.com/guard/listen) that do exactly what I need, but I don't know where I should start the listener and when I should stop it since I need it to run aways my WebApp is online.
You are trying to make too over-complicated things, just because you think Prosody is a "black box". In fact you need:
prosody module, which "hooks" offline message and send it to your webapp - see example here: https://github.com/JorgenPhi/ProsodyPush
push notification module for your favorite web framework - I think you can find tons of ruby gems for it.
After a lot of research, I found that the best way is to write just a simple ruby script and daemonize him with daemons(https://github.com/ghazel/daemons).
To treat the push notification in my rails app I will use the forward_to option from listen to call an action of my rails app.
Thanks to #mtm for the rails cast explaining how to daemonize a script: http://railscasts.com/episodes/129-custom-daemon

Rails Notification Without Page Refresh

I created a simple private messaging app through rails, but I am trying to get it to simply show that new message has arrived without the person having to refresh the page.
I am looking at State Machine because I am thinking that it might be a part of building something like this. Can anyone push me in the right direction?
Thanks.
The simplest way to do that using javascript is to periodically send requests to the server using setTimeout + $.get().
Another a little bit more complicated way is to use gems like faye . There is nice railscast on this theme.
Take a look at any of the messaging protocols like:
Faye
Socket.IO
or hosted sollutions like
PubNub or Pusher

Socky Alternative

I'm in search of a RELIABLE websocket server for ROR 3.Now we're using socky. It is unreliable. We like it because it has flash fallback, so it suppose to work on older browsers...but again - it is unreliable.
Do you know any good websocket server for ROR with fallback (i.e. supporting all browsers)
alternatives are:
socket.io (raw Websocket for NodeJS)
juggernaut (Complete Bayeux Protocol for NodeJS/Rails)
faye (Complete Bayeux Protocol for NodeJS/Rails) with a Ruby-Server
A tip: don't use ruby as websocket server, go for NodeJS - we handle thousands of messages every hour without any issue.
We used the most simple setup possible to make it work - and it works ;)
Our Setup:
Rails 3.0.9
Redis
NodeJS
Socket.IO
How we set it up:
Rails --PUB--> REDIS --SUB--> NodeJS --WEBSOCKET (SOCKET.IO)--> Client
Article Redis PubSub - How does it work?
Another tip: Avoid authentication if possible
Here's our case:
We have something like a project management tool with a virtual filesystem. Let's say you're viewing a folder while someone else of your team uploads a new file. Now we have to inform you that your view is out of the date - we send a message like:
folder_id | last_change_timestamp
to the channel folders:#{folder_id}
now the client (which listens to folders:#{folder_id} receives that messages and sees "whoops my view is out of date" and shows a message "Your view is outdated, please click >here< to refresh".
The good thing is that we don't need any authentication because:
if you have no access to the project you would have to guess the folder_id to subscribe to the channel
even if you manage to subscribe to the channel the only information you get is that something has changed - not more not less ;)

Rails 3.1 - Firing an specific event with the EventMachine

I would like to use the plugin em-eventsource ( https://github.com/AF83/em-eventsource ) for server-sent events in a Rails 3.1-project. My problem is, that there is only explained how to listen on events and receive messages, but not how to fire a specific event up and send the message. I would like to produce the event in an Active Record-Observer. Am I right when I think that I have to defer a operation with EventMachine to produce this event, or how can I solve this?
And yes, it has to be Ruby on Rails. If I don't get this to work with EventMachine, I would try to bypass the whole ruby-part with node.js.
Actually I worked on this library a little with the maintainer. I think you mixed the client part with the server one. em-eventsource is a client library which you can use to consume a ServerSentEvent API, it's not meant to fire SSE.
On the server side, it quite doesn't matter whether you are using Rails or any other stack (nodejs, php…) as long as the server you are running on supports streaming. The default web server shipped with Rails does not (Webrick) but there are many others which do: Thin, Puma, Goliath…
In order to fire SSE in Rails, you would have to use both a streaming-capable server among those cited, and abide by the SSE specification. It mostly falls down to, first, responding with the proper Content-type header ("text/event-stream") so that the client (browser) knows it should hang-on, and then start streaming on the socket. That latter part is the one not easily possible as of today in Rails 3 (yet not impossible!); Rails 4 actually now supports streaming in an easy way, with a clean and simple internal API, so it's definitely coming.
In the mean time, you'd either:
mess with Rack's API in Rails (using EventMachine I guess, there are some examples in the wild)
or have it smart and make use of the streaming feature provided by Sinatra, built on top of Rack (see https://gist.github.com/1476463 for an example of Sinatra app which can be mounted in a Rails one!)
or you could use an external service such as Pusher
or leverage a entirely different stack…
A good overview: http://blog.phusion.nl/2012/08/03/why-rails-4-live-streaming-is-a-big-deal/
Maybe I'm wrong, but if IIRC Rails can't support long pooling. Rails block whole server (or thread if you have more than one running inside server) for each request and can't reuse them unless whole response was send. That's why you should setup reverse proxy (like nginx) in front of Rails application if you suspect there could be many concurrent connections - to proxy slow client requests and send them to Rails when whole request is received. It's just how Rack works, there's not much you can do about this probably.

Sending out lots of mails from Rails - what are people using these days?

In other apps i've used ar_mailer to queue up mails and ar_sendmail to take them out of the queue in a seperate process. I've not been massively happy with this setup: the ar_sendmail process seems to silently die fairly often, and in the default configuration mails are deleted out of the emails table when sent: i'd rather keep them for future reference and just mark them has having been sent.
I'm adding emailing into another project now (which uses rails 2.3.8) and am wondering what other solutions have people used in rails for bulk emailing?
Grateful for any advice - max
I think the prevailing opinion is to use a bulk e-mail service like MailChimp (http://mailchimp.com) or Amazon Simple Email Service (http://aws.amazon.com/ses)

Resources