amq-client 0.9.8 → 0.9.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -274,13 +274,13 @@ module AMQ
274
274
  # @return [Fixnum] Heartbeat interval this client uses, in seconds.
275
275
  # @see http://bit.ly/amqp091reference AMQP 0.9.1 protocol reference (Section 1.4.2.6)
276
276
  def heartbeat_interval
277
- @settings[:heartbeat] || @settings[:heartbeat_interval] || 0
277
+ @heartbeat_interval
278
278
  end # heartbeat_interval
279
279
 
280
280
  # Returns true if heartbeats are enabled (heartbeat interval is greater than 0)
281
281
  # @return [Boolean]
282
282
  def heartbeats_enabled?
283
- self.heartbeat_interval > 0
283
+ @heartbeat_interval && (@heartbeat_interval > 0)
284
284
  end
285
285
 
286
286
 
@@ -608,10 +608,13 @@ module AMQ
608
608
  #
609
609
  # @api plugin
610
610
  # @see http://bit.ly/amqp091reference AMQP 0.9.1 protocol reference (Section 1.4.2.6)
611
- def handle_tune(tune_ok)
612
- @channel_max = tune_ok.channel_max.freeze
613
- @frame_max = tune_ok.frame_max.freeze
614
- @heartbeat_interval = self.heartbeat_interval || tune_ok.heartbeat
611
+ def handle_tune(connection_tune)
612
+ @channel_max = connection_tune.channel_max.freeze
613
+ @frame_max = connection_tune.frame_max.freeze
614
+
615
+ client_heartbeat = @settings[:heartbeat] || @settings[:heartbeat_interval] || 0
616
+
617
+ @heartbeat_interval = negotiate_heartbeat_value(client_heartbeat, connection_tune.heartbeat)
615
618
 
616
619
  self.send_frame(Protocol::Connection::TuneOk.encode(@channel_max, [settings[:frame_max], @frame_max].min, @heartbeat_interval))
617
620
  end # handle_tune(method)
@@ -652,6 +655,14 @@ module AMQ
652
655
 
653
656
  protected
654
657
 
658
+ def negotiate_heartbeat_value(client_value, server_value)
659
+ if client_value == 0 || server_value == 0
660
+ [client_value, server_value].max
661
+ else
662
+ [client_value, server_value].min
663
+ end
664
+ end
665
+
655
666
  # Returns next frame from buffer whenever possible
656
667
  #
657
668
  # @api private
@@ -267,7 +267,7 @@ module AMQ
267
267
  @handling_skipped_hearbeats = false
268
268
  @last_server_heartbeat = Time.now
269
269
 
270
- self.initialize_heartbeat_sender if self.heartbeat_interval > 0
270
+ self.initialize_heartbeat_sender if heartbeats_enabled?
271
271
 
272
272
  self.handshake
273
273
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module AMQ
4
4
  module Client
5
- VERSION = "0.9.8"
5
+ VERSION = "0.9.9"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amq-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.8
4
+ version: 0.9.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2012-11-16 00:00:00.000000000 Z
15
+ date: 2012-11-22 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: eventmachine