Class: Pubnub::Heart
Overview
Heart takes responsibility of heartbeat event
Instance Method Summary collapse
- #beat ⇒ Object
-
#initialize(options) ⇒ Heart
constructor
A new instance of Heart.
- #start_beating ⇒ Object
Constructor Details
#initialize(options) ⇒ Heart
Returns a new instance of Heart.
7 8 9 10 11 |
# File 'lib/pubnub/heart.rb', line 7 def initialize() @heartbeat = [:heartbeat] @channel = [:channel] @app = [:app] end |
Instance Method Details
#beat ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/pubnub/heart.rb', line 26 def beat @app.heartbeat( channel: @channel, heartbeat: @heartbeat, http_sync: true ) end |
#start_beating ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/pubnub/heart.rb', line 13 def start_beating beating = Timers::Group.new beat beating.every(@heartbeat) do Pubnub.logger.debug('Pubnub') { 'Heartbeat!' } beat end loop { beating.wait } end |