examples/multicast.rb in em-websocket-0.0.6 vs examples/multicast.rb in em-websocket-0.1.1

- old
+ new

@@ -23,21 +23,23 @@ @channel.push "#{status['user']['screen_name']}: #{status['text']}" end EventMachine::WebSocket.start(:host => "0.0.0.0", :port => 8080, :debug => true) do |ws| + ws.onopen { - @sid = @channel.subscribe { |msg| ws.send msg } - @channel.push "#{@sid} connected!" - } + sid = @channel.subscribe { |msg| ws.send msg } + @channel.push "#{sid} connected!" - ws.onmessage { |msg| - @channel.push "<#{@sid}>: #{msg}" - } + ws.onmessage { |msg| + @channel.push "<#{sid}>: #{msg}" + } - ws.onclose { - @channel.unsubscribe(@sid) + ws.onclose { + @channel.unsubscribe(sid) + } + } end puts "Server started" -} \ No newline at end of file +}