Integrating WebSockets with Rails using Rack and Event Machine
        Posted  
        
            by 
                Toby Hede
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Toby Hede
        
        
        
        Published on 2010-11-22T10:44:56Z
        Indexed on 
            2012/06/03
            22:40 UTC
        
        
        Read the original article
        Hit count: 320
        
I have created an Asynchronous version of Rails 3 that I would like to integrate with a WebSocket implementation.
I am using EventMachine, Ruby 1.9, Fibers and various em-flavoured libraries as documented by the wickedly good Ilya Grigorik.
I have been looking at em-websocket as the handler for WebSocket connections but unsure of the best approach for hooking this into a Rails app.
Ideally, this would work in a similar fashion to node.js with Express and Socket.io - incoming connections should be detected and dispatched to the WebSocket handler or the regular rails stack as indicated by the HTTP headers & etc.
TL;DR
- WebSocket handler that plugs into an existing Rails application
- Transparently dispatch incoming WebSocket requests to endpoints in the app
© Stack Overflow or respective owner