Ruby on rails chat application over port 80, which hosts the agnostic site (without flash and websockets)

It is required to create a chat application (i.e. a bi-directional message sent to several connected clients). I looked at the Faye gem, but it opens a new port except port 80.

The big problem is that if the client is behind a firewall, all access to ports other than 80 is limited, and not all hosting sites provide support.

There is no client registration mechanism in the ActionController :: Live component so that a message cannot be sent to registered clients when a certain event occurs.

You are looking for a solution in which live clients are stored in a collection (an array or something like that), and when any of the living clients sends a message, the collection can be repeated and messages can be written on it. All this should happen only through port 80.

+3
source share
2 answers

The good question is, having implemented something like this, let me explain how this works:


Connections

A live web application is not really live - it just received a persistent request; which means that it still works exactly the same as the “normal” Rails application, except that clients do not close the connection (therefore, why are you interested in opening another port).

- , . , Rails ( )


"chat", . ( Ajax) -

, Rails ActionDispatch,

ActionController:: Live, , . (, resque Redis), .


, - , "" "" Rails-. Rails - , , - nodeJS socket.io ( , chat.yourapp.com), Rails

- , . , , , , , "" . , , .


, Pusher

-, Rails Redis ( )

, Rails (http://yourapp.com/chat), Rails (http://yourapp.com/chat/send) ( )

+1

All Articles