Class: EventMachine::RTMP::Heartbeat

Inherits:
ConnectionDelegate show all
Defined in:
lib/em-rtmp/heartbeat.rb

Instance Attribute Summary

Attributes inherited from ConnectionDelegate

#state

Instance Method Summary collapse

Methods inherited from ConnectionDelegate

#bytes_waiting, #change_state, #read, #write

Methods included from IOHelpers

#read_bitfield, #read_double_be, #read_int29, #read_safe, #read_uint16_be, #read_uint24_be, #read_uint32_be, #read_uint32_le, #read_uint8, #write_bitfield, #write_double_be, #write_int29, #write_uint16_be, #write_uint24_be, #write_uint32_be, #write_uint32_le, #write_uint8

Constructor Details

#initialize(connection) ⇒ Heartbeat

Returns a new instance of Heartbeat.



5
6
7
# File 'lib/em-rtmp/heartbeat.rb', line 5

def initialize(connection)
  super connection
end

Instance Method Details

#buffer_changedObject



9
10
11
# File 'lib/em-rtmp/heartbeat.rb', line 9

def buffer_changed

end

#cancelObject



29
30
31
32
# File 'lib/em-rtmp/heartbeat.rb', line 29

def cancel
  @timer.cancel
  @timer = nil
end

#pulseObject



25
26
27
# File 'lib/em-rtmp/heartbeat.rb', line 25

def pulse
  @block.call
end

#startObject



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/em-rtmp/heartbeat.rb', line 13

def start
  @timer ||= EventMachine::PeriodicTimer.new(15) do
    pulse
  end

  @block = Proc.new do
    Logger.debug "Heartbeat Pulsing"
  end

  @block.call
end