jonathanrz
jonathanrz

Reputation: 4296

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.

Upvotes: 0

Views: 807

Answers (2)

vitalyster
vitalyster

Reputation: 5266

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.

Upvotes: 1

jonathanrz
jonathanrz

Reputation: 4296

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

Upvotes: 0

Related Questions