Module: Faye::Timeouts
- Included in:
- Engine::Connection, Engine::Memory, Transport
- Defined in:
- lib/faye/mixins/timeouts.rb
Instance Method Summary collapse
Instance Method Details
#add_timeout(name, delay, &block) ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'lib/faye/mixins/timeouts.rb', line 3 def add_timeout(name, delay, &block) Engine.ensure_reactor_running! @timeouts ||= {} return if @timeouts.has_key?(name) @timeouts[name] = EventMachine.add_timer(delay) do @timeouts.delete(name) block.call end end |
#remove_timeout(name) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/faye/mixins/timeouts.rb', line 13 def remove_timeout(name) @timeouts ||= {} timeout = @timeouts[name] return if timeout.nil? EventMachine.cancel_timer(timeout) @timeouts.delete(name) end |