Skip to content

Instantly share code, notes, and snippets.

@lifo
Created November 19, 2008 03:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save lifo/26399 to your computer and use it in GitHub Desktop.
Save lifo/26399 to your computer and use it in GitHub Desktop.
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