Sha256: 0856e5ddebe60cae69b2dc738859955f20a64d9daf2d4e1561e3b8a1c8a2ee6d

Contents?: true

Size: 638 Bytes

Versions: 30

Compression:

Stored size: 638 Bytes

Contents

# Toplevel Pubnub module.
module Pubnub
  # Heart takes responsibility of heartbeat event
  class Heart
    include Celluloid

    def initialize(options)
      @heartbeat = options[:heartbeat]
      @channel   = options[:channel]
      @app       = options[:app]
    end

    def start_beating
      beating = Timers::Group.new

      beat

      beating.every(@heartbeat) do
        Pubnub.logger.debug('Pubnub') { 'Heartbeat!' }
        beat
      end

      loop { beating.wait }
    end

    def beat
      @app.heartbeat(
        channel:   @channel,
        heartbeat: @heartbeat,
        http_sync: true
      )
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
pubnub-4.0.27 lib/pubnub/heart.rb
pubnub-4.0.25 lib/pubnub/heart.rb
pubnub-4.0.23 lib/pubnub/heart.rb
pubnub-4.0.22 lib/pubnub/heart.rb
pubnub-4.0.21 lib/pubnub/heart.rb
pubnub-4.0.20 lib/pubnub/heart.rb
pubnub-4.0.19 lib/pubnub/heart.rb
pubnub-3.8.5 lib/pubnub/heart.rb
pubnub-3.8.4 lib/pubnub/heart.rb
pubnub-4.0.18 lib/pubnub/heart.rb
pubnub-4.0.17 lib/pubnub/heart.rb
pubnub-4.0.16 lib/pubnub/heart.rb
pubnub-4.0.15 lib/pubnub/heart.rb
pubnub-4.0.14 lib/pubnub/heart.rb
pubnub-4.0.13 lib/pubnub/heart.rb
pubnub-4.0.12 lib/pubnub/heart.rb
pubnub-4.0.9 lib/pubnub/heart.rb
pubnub-4.0.8 lib/pubnub/heart.rb
pubnub-4.0.7 lib/pubnub/heart.rb
pubnub-3.8.2 lib/pubnub/heart.rb