title: Using WebSockets with EM and IRC to Send "Connection Successful" Message
body: <p>I'm attempting to write an IRC client using WebSockets. The IRC client I found on GitHub uses EventMachine, but I'm trying to use WebSockets as well to notify any connected clients when they're connected. However, I don't think I'm quite understanding EventMachine, because although the client successfully connects and joins the IRC channel, the <code>puts 'Connected...'</code> nor the subsequent line gets executed.</p>
  
  <p>I assume this is because of a fundamental misunderstanding of EventMachine on my behalf.</p>
  
  <pre><code>EM.run {
  
    EventMachine::WebSocket.start(:host =&gt; '0.0.0.0', :port =&gt; 8080) do |websocket|
  
      websocket.onopen {
  
        irc = Net::YAIL.new(
            :address    =&gt; 'irc.my-example-server.net',
            :port       =&gt; 6667,
            :username   =&gt; 'MyExample',
            :realname   =&gt; 'My Example Bot',
            :nicknames  =&gt; ['MyExample1', 'MyExample2', 'MyExample3']
        )
  
        irc.on_welcome proc { |event|
          irc.join('#ExampleChannel')
          EM.next_tick {
            puts 'Connected...'
            websocket.send({ :message =&gt; 'Connected' })
          }
        }
  
        irc.start_listening!
      }
  
    end
  </code></pre>
  
  <p>}</p>