class EventMachineLoop

Public Class Methods

new(loops) click to toggle source
# File dev/net_http.rb, line 47
def initialize loops
  @total_loops, @loops = loops, 0
end

Public Instance Methods

all_requests_done?() click to toggle source
# File dev/net_http.rb, line 64
def all_requests_done?
  @loops >= @total_loops
end
request!() click to toggle source
# File dev/net_http.rb, line 51
def request!
  http = EventMachine::HttpRequest.new('http://localhost:3000').get
  http.callback { |http|
    @loops += 1
    http.response
    all_requests_done? ? EM.stop : request!
  }
  http.errback { |http|
    puts "EventMachine Request Error: #{http.error} #{http.inspect}"
    EM.stop
  }
end