Sha256: 455a2b999a9902302cd6ae6aa6df37c75a56ed0960b81198a28475cb43314ca2

Contents?: true

Size: 1.16 KB

Versions: 10

Compression:

Stored size: 1.16 KB

Contents

require 'rubygems'
require 'bundler/setup'
require 'faye/websocket'
require 'cgi'
require 'progressbar'

EM.run {
  host  = 'ws://localhost:9001'
  ruby  = RUBY_PLATFORM =~ /java/ ? 'JRuby' : 'MRI'
  agent = "#{ruby} #{RUBY_VERSION}"
  cases = 0
  skip  = []

  socket   = Faye::WebSocket::Client.new("#{host}/getCaseCount")
  progress = nil

  socket.onmessage = lambda do |event|
    puts "Total cases to run: #{event.data}"
    cases = event.data.to_i
    progress = ProgressBar.new('Autobahn', cases)
  end

  socket.onclose = lambda do |event|
    run_case = lambda do |n|
      progress.inc

      if n > cases
        socket = Faye::WebSocket::Client.new("#{host}/updateReports?agent=#{CGI.escape agent}")
        progress.finish
        socket.onclose = lambda { |e| EM.stop }

      elsif skip.include?(n)
        EM.next_tick { run_case.call(n+1) }

      else
        socket = Faye::WebSocket::Client.new("#{host}/runCase?case=#{n}&agent=#{CGI.escape agent}")

        socket.onmessage = lambda do |event|
          socket.send(event.data)
        end

        socket.on :close do |event|
          run_case.call(n + 1)
        end
      end
    end

    run_case.call(1)
  end
}

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
faye-websocket-0.7.3 examples/autobahn_client.rb
faye-tls1-websocket-0.8.0 examples/autobahn_client.rb
faye-websocket-0.7.2 examples/autobahn_client.rb
faye-websocket-0.7.1 examples/autobahn_client.rb
faye-websocket-0.7.0 examples/autobahn_client.rb
faye-websocket-0.6.3 examples/autobahn_client.rb
faye-websocket-0.6.2 examples/autobahn_client.rb
faye-websocket-0.6.1 examples/autobahn_client.rb
faye-websocket-0.6.0 examples/autobahn_client.rb
faye-websocket-0.5.0 examples/autobahn_client.rb