0

I have the following code snippet using sinatra/async where it seems the call to second body statement is skipped. All the examples on the web seem to say this should work. How do I send push notification ?

aget '/result' do
    body 'Here are the results: <br/>'
    @@result.each do |item|
        filename = item[:title]+'.out'
        File.open(File.join(@@directory, filename), "w") do |f|
            f.write(URI.parse(item[:url]).read)
        end
        body "File #{filename} has been created.<br/>"
    end
end

I am running on Thin v1.2.11

Sam
  • 1
  • Pretty sure you can only call 'body' once. It kind of looks like you're talking about two different things here. a) async push and possibly b) streaming your response. The two do not necessarily have anything to do with each other. What precisely do you want the behavior to be? Or put another way, what is going to "consume" your output? – bioneuralnet Sep 06 '11 at 21:02
  • It is a simple notification window where I should be able to see the result of the file operation. I have been trying to adapt this (http://stackoverflow.com/questions/4964828/stream-multiple-body-using-async-sinatra) to my code but have been unable to. – Sam Sep 06 '11 at 22:04
  • Seems like sinatra-1.3.0 will have the helper method 'stream' for what I want according to the "Streaming Responses" section at Github ... https://github.com/sinatra/sinatra – Sam Sep 06 '11 at 23:38
  • Awesome, I hadn't seen that. In the meantime, you may be able to adapt this http://stackoverflow.com/questions/3669674/streaming-data-from-sinatra-rack-application. – bioneuralnet Sep 07 '11 at 04:14

0 Answers0