Created
November 19, 2008 03:10
-
-
Save lifo/26399 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AsyncApp | |
# This is a template async response. N.B. Can't use string for body on 1.9 | |
AsyncResponse = [-1, {}, []].freeze | |
def call(env) | |
body = DeferrableBody.new | |
EventMachine::next_tick { env['async.callback'].call [200, {'Content-Type' => 'text/plain'}, body] } | |
EventMachine::add_periodic_timer(3) do | |
EventMachine::next_tick { body.call ["Cheers then!"] } | |
# body.succeed | |
end | |
AsyncResponse | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment