title: websocket-rails connection initialization - dispatcher.state stuck on "connecting"
body: <p>I am trying to set up a basic websocket from client to my RoR app.  I've used websocket-rails gem for that matter.</p>
  
  <p>I've set up a simple eventMap mapping.
  config/events.rb:</p>
  
  <pre><code>WebsocketRails::EventMap.describe do
    namespace :tasks do
      subscribe :create, :to =&gt; TaskController, :with_method =&gt; :create
    end
  end
  </code></pre>
  
  <p>And a simple controller:
  app/controller/task_controller.rb:</p>
  
  <pre><code>class TaskController &lt; WebsocketRails::BaseController
    def create
      puts "In task create"
      send_message :create_success, task, :namespace =&gt; :tasks
    end
  end
  </code></pre>
  
  <p>And finally an initialization from client side:</p>
  
  <pre><code>$(function() {
     var task = {
       name: 'Start taking advantage of WebSockets',
       completed: false
     }
  
     var dispatcher = new WebSocketRails('localhost:3000/websocket');
  
     dispatcher.on_open = function(data) {
       alert("on_open");
        console.log('Connection has been established: ', data);
       // You can trigger new server events inside this callback if you wish.
     } 
  
  
     $("#ws-test").click(function() {
        dispatcher.trigger('tasks.create', task);
     });
  
     dispatcher.bind('tasks.create_success', function(task) {
       console.log('successfully created ' + task.name);
      })
  
  });
  </code></pre>
  
  <p>When accessing the page which triggers this code, In network traffic I see the request to ws://localhost:3000/websocket. 
  That request is returned with status code <strong>101 Switching Protocols</strong>.
  No errors in js nor logs on server side.</p>
  
  <p>This is where I get confused. By RFC 101 means the handshake succeeded, so I thought the connection initialization finished fine.
  However, when inspecting and debugging client side, dispatcher.state remains in "connecting". <br/>
  When trying to invoke dispatcher.trigger, nothing happens. <br/>
  When debugging websocket-rails inner code, during trigger there is a check for dispatcher.state and in case it's not "connected", it pushes it to queue instead of proceeding to handle it. <br/></p>
  
  <p>And this is how it's stuck forever. Tested on Mozilla Firefox 33.0 and on Chrome Version 38.0.2125.104 <br/></p>
  
  <p>Any insights would be appreciated.</p>
  
  <p>ruby 2.0.0p576 <br/>
  Rails 4.1.1 <br/>
  websocket-rails-0.7.0 <br/></p>