class Sinapse::KeepAlive
Public Class Methods
new()
click to toggle source
# File lib/sinapse/keep_alive.rb, line 3 def initialize @queue = [] end
Public Instance Methods
<<(env)
click to toggle source
# File lib/sinapse/keep_alive.rb, line 7 def <<(env) @queue << env @timer = start if @queue.size == 1 end
delete(env)
click to toggle source
# File lib/sinapse/keep_alive.rb, line 12 def delete(env) @queue.delete(env) @timer.cancel if @timer && @queue.size == 0 end
Protected Instance Methods
start()
click to toggle source
# File lib/sinapse/keep_alive.rb, line 19 def start EM.add_periodic_timer(Config.keep_alive) do @queue.each { |env| env.chunked_stream_send ":\n" } end end