Class: Pubnub::Heart
Overview
Heart takes responsibility of heartbeat event
Instance Method Summary (collapse)
- - (Object) beat
-
- (Heart) initialize(options)
constructor
A new instance of Heart.
- - (Object) start_beating
Constructor Details
- (Heart) initialize(options)
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
- (Object) beat
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 |
- (Object) start_beating
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 |