mqtt 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/NEWS.md +7 -1
- data/lib/mqtt/client.rb +6 -1
- data/lib/mqtt/version.rb +1 -1
- data/spec/mqtt_client_spec.rb +7 -0
- metadata +2 -2
data/NEWS.md
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
Ruby MQTT NEWS
|
2
2
|
==============
|
3
3
|
|
4
|
+
Ruby MQTT Version 0.3.1 (2014-10-10)
|
5
|
+
------------------------------------
|
6
|
+
|
7
|
+
* Added ```last_ping_response``` to attribute to ```MQTT::Client```
|
8
|
+
|
9
|
+
|
4
10
|
Ruby MQTT Version 0.3.0 (2014-08-26)
|
5
11
|
------------------------------------
|
6
12
|
|
@@ -11,7 +17,7 @@ Ruby MQTT Version 0.3.0 (2014-08-26)
|
|
11
17
|
- Renamed ```:remote_host``` to ```:host```
|
12
18
|
- Renamed ```:message_id``` to ```:id```
|
13
19
|
- Renamed ```:protocol_version``` to ```:protocol_level```
|
14
|
-
- Renamed ```
|
20
|
+
- Renamed ```MQTT_BROKER``` environment variable to ```MQTT_SERVER```
|
15
21
|
* Added more checks to ensure that the 3.1.1 protocol specs are adhered to
|
16
22
|
* Added a Library Overview section to the README
|
17
23
|
* Added links to the protocol specification to README
|
data/lib/mqtt/client.rb
CHANGED
@@ -53,6 +53,9 @@ class MQTT::Client
|
|
53
53
|
# If the Will message should be retain by the server after it is sent
|
54
54
|
attr_accessor :will_retain
|
55
55
|
|
56
|
+
#Last ping response time
|
57
|
+
attr_reader :last_ping_response
|
58
|
+
|
56
59
|
|
57
60
|
# Timeout between select polls (in seconds)
|
58
61
|
SELECT_TIMEOUT = 0.5
|
@@ -173,7 +176,7 @@ class MQTT::Client
|
|
173
176
|
# Initialise private instance variables
|
174
177
|
@packet_id = 0
|
175
178
|
@last_pingreq = Time.now
|
176
|
-
@
|
179
|
+
@last_ping_response = Time.now
|
177
180
|
@socket = nil
|
178
181
|
@read_queue = Queue.new
|
179
182
|
@read_thread = nil
|
@@ -452,6 +455,8 @@ private
|
|
452
455
|
if packet.class == MQTT::Packet::Publish
|
453
456
|
# Add to queue
|
454
457
|
@read_queue.push(packet)
|
458
|
+
elsif packet.class == MQTT::Packet::Pingresp
|
459
|
+
@last_ping_response = Time.now
|
455
460
|
else
|
456
461
|
# Ignore all other packets
|
457
462
|
nil
|
data/lib/mqtt/version.rb
CHANGED
data/spec/mqtt_client_spec.rb
CHANGED
@@ -736,6 +736,13 @@ describe MQTT::Client do
|
|
736
736
|
client.send(:receive_packet)
|
737
737
|
end
|
738
738
|
|
739
|
+
it "should update last_ping_response when receiving a Pingresp" do
|
740
|
+
allow(MQTT::Packet).to receive(:read).and_return MQTT::Packet::Pingresp.new
|
741
|
+
client.instance_variable_set '@last_ping_response', Time.at(0)
|
742
|
+
client.send :receive_packet
|
743
|
+
expect(client.last_ping_response).to be_within(1).of Time.now
|
744
|
+
end
|
745
|
+
|
739
746
|
it "should close the socket if there is an exception" do
|
740
747
|
expect(socket).to receive(:close).once
|
741
748
|
allow(MQTT::Packet).to receive(:read).and_raise(MQTT::Exception)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mqtt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-10-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|