I would like to start a long polling request from javascript, which is good, and I expect my ruby prose to pass multiple sections of the body into javascript. Why doesn't the following (pseudo) code work?
require 'rubygems'
require 'sinatra/async'
require 'eventmachine'
require 'thin'
require 'json'
class Test < Sinatra:Base
register Sinatra::Async
aget '/process' do
for c in 1..10
body {
{ :data => [ "this is part #{c}" ] }.to_json
end
end
end
run!
end
Maybe I misunderstood what a long survey and asink should do, but I expect that I will receive several bodies sent back to the client? Do I need to use eventmachine or something else?
thank
source
share