Sha256: 121cf13687627b38a92e7ca09aa61b4edee0cf98578003932e7fe4a25d5d2b5a
Contents?: true
Size: 648 Bytes
Versions: 1
Compression:
Stored size: 648 Bytes
Contents
module Endless class App < Sinatra::Base register Sinatra::Async class DataStream include EventMachine::Deferrable def stream(data) @block.call(data) end def each(&block) @block = block end end def randomLetters(length) s = [] length.times do s << 97+rand(26) end s.pack('c' * s.size) end aget '/endless' do out = DataStream.new body(out) EM.next_tick do timer = EM.add_periodic_timer(0.001) do s = randomLetters(8191) s << "\n" out.stream(s) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
endless-0.0.1 | lib/endless/app.rb |