several response body#close fixes
[rainbows.git] / t / cramp / streaming.ru
blobdc470b2ada4e409b13204b805d619cabb31af35f
1 # based on examples/streaming.rb in git://github.com/lifo/cramp
2 # commit ca54f8a944ae582a0c858209daf3c74efea7d27c
4 # Rack::Lint does not like async + EM stuff, so disable it:
5 #\ -E deployment
7 require 'cramp/controller'
9 class StreamController < Cramp::Controller::Action
10   periodic_timer :send_data, :every => 1
11   periodic_timer :check_limit, :every => 2
13   def start
14     @limit = 0
15   end
17   def send_data
18     render ["Hello World", "\n"]
19   end
21   def check_limit
22     @limit += 1
23     finish if @limit > 1
24   end
26 end
28 run StreamController