Transfer data from rails application to clients

I am working on a rail application that will primarily display api for various mobile clients (iOS, android, etc.). The application includes users sending data to the server (via api calls), but what I want to enable is the ability to transfer this data to other clients. The general concept is similar to a messaging application where I send a message to the server from my client, and the receiver pushes the message from the server.

The only method that I know at the moment is to constantly poll the server, but there must be better technological solutions than this. Any ideas?

+8
push ruby-on-rails
source share
4 answers

You should check out http://www.pusher.com

Pusher is a hosted API for quickly, easily and safely adding scalable real-time features to web and mobile applications.

If you need a self-hosting solution, you should check out zanger gem https://github.com/stevegraham/slanger , which is the server implementation for the proprietary client libraries. When you feel that you need a hosting solution, you simply change the URL.

Slanger is an open source server implementation of the Pusher protocol written in Ruby. It is intended for horizontal scaling across N nodes and for agnostics to which the Slanger node is connected to the subscriber, that is, subscribers of the same channel should NOT connect to the same Slanger node. Several Slanger nodes can be located behind the load balancer without special configuration. In fact, it was designed for very easy scaling.

+4
source share

I would see how to use websocket inside the page for updating.

You can implement this with Faye , which returns to lengthy polls and other workarounds for browsers without websocket support. Faye has a pure ruby โ€‹โ€‹implementation, so you can probably access your model level.

Edit:

It is also a project that integrates Faye with Rails. This is fairly new, but it can do what you want. Faye-rails

+4
source share

Ruby has its own event processing library, implemented as a gem:

https://github.com/eventmachine/eventmachine

Maybe this will help you

+2
source share

I prefer the event machine over any other solution. This is somewhat more complicated than faye, but you can write more complex code using the event machine.

You might want to check out this peepcode screencast on an event machine

+1
source share

All Articles