Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tag: v0.14.1
Fetching contributors…

Cannot retrieve contributors at this time

37 lines (27 sloc) 0.638 kb
require "rubygems"
require "bundler"
Bundler.setup(:default, :example)
require 'cramp'
require 'thin'
class LazyController < Cramp::LongPolling
on_start :init_limit
periodic_timer :check_limit, :every => 1
def init_limit
@limit = 0
end
def check_limit
@limit += 1
if @limit > 20
puts "And the wait is over !!!"
# Send back a response to the client. Terminate the request.
render "Hello World!"
else
puts "You must wait"
end
end
def respond_with
[200, {'Content-Type' => 'text/plain'}]
end
end
# bundle exec thin -V -R examples/long_poll.ru start
run LazyController
Jump to Line
Something went wrong with that request. Please try again.