Sha256: c0f980219c4b8746a1d7f4844bbea96ffeec5e26af89e43b64d7b2aa5d8a40c2
Contents?: true
Size: 1.14 KB
Versions: 2
Compression:
Stored size: 1.14 KB
Contents
require 'rubygems' require 'bundler/setup' require 'cgi' require 'faye/websocket' require 'permessage_deflate' require 'progressbar' EM.run { host = 'ws://localhost:9001' ruby = RUBY_PLATFORM =~ /java/ ? 'jruby' : 'cruby' agent = CGI.escape("#{ruby}-#{RUBY_VERSION}") cases = 0 options = {:extensions => [PermessageDeflate]} 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.create(:title => 'Autobahn', :total => cases) end run_case = lambda do |n| if n > cases socket = Faye::WebSocket::Client.new("#{host}/updateReports?agent=#{agent}") socket.onclose = lambda { |e| EM.stop } next end url = "#{host}/runCase?case=#{n}&agent=#{agent}" socket = Faye::WebSocket::Client.new(url, [], options) socket.onmessage = lambda do |event| socket.send(event.data) end socket.on :close do |event| progress.increment run_case[n + 1] end end socket.onclose = lambda do |event| run_case[1] end }
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
faye-websocket-0.10.7 | examples/autobahn_client.rb |
faye-websocket-0.10.6 | examples/autobahn_client.rb |