mqtt-ccutrer 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mqtt/client.rb +15 -5
- data/lib/mqtt/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b93bce8e1cc0e50a0161ac2447fbff2c293ad89f64dc98cb848e20026e754e3
|
4
|
+
data.tar.gz: 4b480e5ffb4df550469d112274f6c831b96f4a2118bb29e32940156b9dccce58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3227b778e824d891845cab272ffe73f875ffe2de3440a56e1a3f73bffb5d6fa9edb41844665aead5411276c0241ef4f176fc369b98d1398c54bbdf78dc9103d9
|
7
|
+
data.tar.gz: 51254e256507a8c01dd9197266eed692ccad64c3a7b0baa8bbc3ec50350ea712bc2a8bbfd1b575fca4527d5fe4da0a706f33aa998a932aca8a517f5af40b6721
|
data/lib/mqtt/client.rb
CHANGED
@@ -173,6 +173,9 @@ module MQTT
|
|
173
173
|
@wake_up_pipe = IO.pipe
|
174
174
|
|
175
175
|
@connected = false
|
176
|
+
@keep_alive_sent = false
|
177
|
+
@last_packet_id = 0
|
178
|
+
@batch_publish = false
|
176
179
|
end
|
177
180
|
|
178
181
|
# Get the OpenSSL context, that is used if SSL/TLS is enabled
|
@@ -514,6 +517,7 @@ module MQTT
|
|
514
517
|
|
515
518
|
# Send packet
|
516
519
|
@socket.write(packet.to_s)
|
520
|
+
@last_packet_sent_at = current_time
|
517
521
|
|
518
522
|
# Receive response
|
519
523
|
receive_connack
|
@@ -528,6 +532,7 @@ module MQTT
|
|
528
532
|
next
|
529
533
|
end
|
530
534
|
@socket.write(packet.to_s)
|
535
|
+
@last_packet_sent_at = current_time
|
531
536
|
end
|
532
537
|
rescue => e
|
533
538
|
@write_queue << packet if packet
|
@@ -643,7 +648,7 @@ module MQTT
|
|
643
648
|
# Add to queue
|
644
649
|
@read_queue.push(packet)
|
645
650
|
when MQTT::Packet::Pingresp
|
646
|
-
# do nothing; setting @
|
651
|
+
# do nothing; setting @keep_alive_sent already handled it
|
647
652
|
when MQTT::Packet::Puback,
|
648
653
|
MQTT::Packet::Suback,
|
649
654
|
MQTT::Packet::Unsuback
|
@@ -694,8 +699,13 @@ module MQTT
|
|
694
699
|
end
|
695
700
|
return nil if timeout_from_acks.nil? && @keep_alive.nil?
|
696
701
|
|
697
|
-
|
698
|
-
|
702
|
+
if @keep_alive
|
703
|
+
next_ping = if @keep_alive_sent
|
704
|
+
@last_packet_received_at + @keep_alive + @ack_timeout
|
705
|
+
else
|
706
|
+
@last_packet_sent_at + @keep_alive
|
707
|
+
end
|
708
|
+
end
|
699
709
|
current_time_local = current_time
|
700
710
|
[([timeout_from_acks, next_ping].compact.min || current_time_local) - current_time_local, 0].max
|
701
711
|
end
|
@@ -704,7 +714,7 @@ module MQTT
|
|
704
714
|
return unless @keep_alive && @keep_alive > 0
|
705
715
|
|
706
716
|
current_time_local = current_time
|
707
|
-
if current_time_local >= @
|
717
|
+
if current_time_local >= @last_packet_sent_at + @keep_alive && !@keep_alive_sent
|
708
718
|
packet = MQTT::Packet::Pingreq.new
|
709
719
|
send_packet(packet)
|
710
720
|
@keep_alive_sent = true
|
@@ -764,7 +774,7 @@ module MQTT
|
|
764
774
|
end
|
765
775
|
|
766
776
|
def next_packet_id
|
767
|
-
@last_packet_id =
|
777
|
+
@last_packet_id = @last_packet_id.next
|
768
778
|
@last_packet_id = 1 if @last_packet_id > 0xffff
|
769
779
|
@last_packet_id
|
770
780
|
end
|
data/lib/mqtt/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mqtt-ccutrer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cody Cutrer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|