Module: Stomper::Extensions::Heartbeat

Included in:
Connection
Defined in:
lib/stomper/extensions/heartbeat.rb

Overview

Provides the heart-beating interface for a Connection object.

Defined Under Namespace

Modules: V1_1

Constant Summary collapse

EXTEND_BY_VERSION =

A mapping between protocol versions and modules to include

{
  '1.0' => [ ],
  '1.1' => [ ::Stomper::Extensions::Heartbeat::V1_1 ]
}

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extend_by_protocol_version(instance, version) ⇒ Object

Extends an object with any additional modules that are appropriate for the Stomp protocol being used.



7
8
9
10
11
12
13
# File 'lib/stomper/extensions/heartbeat.rb', line 7

def self.extend_by_protocol_version(instance, version)
  if EXTEND_BY_VERSION[version]
    EXTEND_BY_VERSION[version].each do |mod|
      instance.extend mod
    end
  end
end

Instance Method Details

#alive?true, false

By default, a connection is alive if it is Connection#connected?. If the established connection utilizes the Stomp 1.1 protocol, this method will be overridden by Protocols::V1_1::Heartbeating#alive?.

Returns:

  • (true, false)

See Also:



25
26
27
# File 'lib/stomper/extensions/heartbeat.rb', line 25

def alive?
  connected?
end

#beatObject

By default, this method does nothing. If the established connection utilizes the Stomp 1.1 protocol, this method will be overridden by Protocols::V1_1::Heartbeating#beat.



18
# File 'lib/stomper/extensions/heartbeat.rb', line 18

def beat; end

#dead?true, false

A connection is dead if it is not alive?

Returns:

  • (true, false)

See Also:



32
33
34
# File 'lib/stomper/extensions/heartbeat.rb', line 32

def dead?
  !alive?
end