Sha256: 27b7e441988eebaff752ae7f91ca21602c7d6e88f72c4d37e449aa47b95f5fd7
Contents?: true
Size: 1.08 KB
Versions: 2
Compression:
Stored size: 1.08 KB
Contents
require File.expand_path('../../lib/websocket-eventmachine-client', __FILE__) require 'cgi' EM.epoll EM.run do host = 'ws://localhost:9001' agent = "WebSocket-EventMachine-Client (1.0.0)" cases = 0 skip = [] ws = WebSocket::EventMachine::Client.connect(:uri => "#{host}/getCaseCount") ws.onmessage do |msg, type| puts "$ Total cases to run: #{msg}" cases = msg.to_i end ws.onclose do run_case = lambda do |n| if n > cases puts "$ Requesting report" ws = WebSocket::EventMachine::Client.connect(:uri => "#{host}/updateReports?agent=#{CGI.escape agent}") ws.onclose do EM.stop end elsif skip.include?(n) EM.next_tick { run_case.call(n+1) } else ws = WebSocket::EventMachine::Client.connect(:uri => "#{host}/runCase?case=#{n}&agent=#{CGI.escape agent}") ws.onmessage do |msg, type| ws.send(msg, :type => type) end ws.onclose do |msg| EM.add_timer(0.1) { run_case.call(n + 1) } end end end run_case.call(1) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
websocket-eventmachine-client-1.0.1 | examples/autobahn_client.rb |
websocket-eventmachine-client-1.0.0 | examples/autobahn_client.rb |