How to implement websocket-based push service through Rails?
Asked Answered
B

1

7

I'm building a messaging app like WhatsApp. My goal is to expose only REST API through Rails and "push notifications" to connected clients via websockets. So clients communicate with server only with the REST API. Only the server sends data through the websocket. Clients can only receive data from it.

Currently I've built an eventmachine server listening for websocket connections and Unix domain socket connections. When a client performs a request on the REST API, Rails connects to the Unix domain socket to tell the eventmachine what connected client needs to be notified through the websocket.

My concern is about how it will behave in production (my server runs Apache Passenger). So I'm looking for some project to solve my problem. I had a look at Faye but I can't understand how to force it to send notifications to connected clients from an external process (that might be rails while is performing a request). Any ideas?

Blowy answered 26/7, 2013 at 15:11 Comment(0)
L
0

Have you looked at the sync gem I am doing something similar and that is what i use

https://github.com/chrismccord/sync

They have a really good video on integration and a example https://github.com/chrismccord/sync_example

and this fully supports Faye and Pusher.

I use Faye for dev and Pusher for production

Liver answered 22/12, 2013 at 0:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.