Pregunta

I want to build a instant messaging application using Ruby on Rails but I'm confused about the implementation.

How is a IM application (like the one on Facebook) usually implemented? I think we can use a push server (server pushes to client) or polling (client asks the server), but is there any other ways? And what are the corresponding advantages of these two approaches? Which one is usually more efficient and less demanding?

Thanks in advance.

¿Fue útil?

Solución

I don't know specifically how Facebook implements their IM service, but most web-based IM clients use either a push server or a Jabber client. Jabber is good if you want the users to be able to communicate with the service through their own IM client, and not just through the web frontend; push is good if you're doing something interesting with the received messages on the server-side. Polling isn't used anywhere near as widely nowadays. It requires the same JavaScript support as server push, but is much more resource-intensive for your server.

For getting started with push, I would recommend looking into Faye or Juggernaut.

If you're interested in Jabber options, check out the JavaScript Jabber Client Library.

Otros consejos

  1. Polling: In case of Polling, browser makes the request to server at a regular interval to check for updates. It will increase your server load.

  2. Server Sent Events: server sent events. Server-Sent Events have been designed from the ground up to be efficient. When communicating using SSEs, a server can push data to your app whenever it wants, without the need to make an initial request.

  3. WebSockets: WebSockets on the other hand, require full-duplex connections and new Web Socket servers to handle the protocol.

For IM best suited is websocket, as using websocket you can do bi-directional communication.

A similar example of IM using websocket is Applozic chat SDK. It Uses web sockets for Real Time Messaging.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top