paho-mqtt 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/paho-mqtt.rb +1 -0
- data/lib/paho_mqtt/client.rb +17 -8
- data/lib/paho_mqtt/connection_helper.rb +1 -0
- data/lib/paho_mqtt/version.rb +1 -1
- data/samples/{client_blocking.rb → client_blocking(reading).rb} +2 -6
- data/samples/getting_started.rb +1 -1
- data/samples/test_client.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80ab469d38120ae2f9cdcb6901ecc3f82e31cdca
|
4
|
+
data.tar.gz: 2ac290819f952a35d16708d78105acac6edd10dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 022c3db947547fd72a9b7cdba15a1c60d5a0412ffed0e31bfca54e934178ba1a0d30935b9bba49402959bf9a91ff9c3e2dc3ceff51fb3806ed657e1c3e90240b
|
7
|
+
data.tar.gz: 22712df65d41429e9c16d3f34ebf4130af07c2b026f7ab4a6eadc8712181844d358c6030c529ec18ac363e41ee9fa4268019bab60a7615ff1737085c8df76293
|
data/lib/paho-mqtt.rb
CHANGED
data/lib/paho_mqtt/client.rb
CHANGED
@@ -111,18 +111,28 @@ module PahoMqtt
|
|
111
111
|
@connection_helper.send_connect(session_params)
|
112
112
|
begin
|
113
113
|
@connection_state = @connection_helper.do_connect(reconnect?)
|
114
|
+
if connected?
|
115
|
+
build_pubsub
|
116
|
+
daemon_mode unless @blocking
|
117
|
+
end
|
114
118
|
rescue LowVersionException
|
115
119
|
downgrade_version
|
116
120
|
end
|
117
|
-
build_pubsub
|
118
|
-
daemon_mode unless @blocking || !connected?
|
119
121
|
end
|
120
122
|
|
121
123
|
def daemon_mode
|
122
124
|
@mqtt_thread = Thread.new do
|
123
125
|
@reconnect_thread.kill unless @reconnect_thread.nil? || !@reconnect_thread.alive?
|
124
|
-
|
125
|
-
|
126
|
+
begin
|
127
|
+
while connected? do
|
128
|
+
mqtt_loop
|
129
|
+
end
|
130
|
+
rescue SystemCallError => e
|
131
|
+
if @persistent
|
132
|
+
reconnect()
|
133
|
+
else
|
134
|
+
raise e
|
135
|
+
end
|
126
136
|
end
|
127
137
|
end
|
128
138
|
end
|
@@ -176,21 +186,20 @@ module PahoMqtt
|
|
176
186
|
@subscriber.check_waiting_subscriber
|
177
187
|
end
|
178
188
|
|
179
|
-
def reconnect
|
189
|
+
def reconnect
|
180
190
|
@reconnect_thread = Thread.new do
|
181
|
-
|
191
|
+
RECONNECT_RETRY_TIME.times do
|
182
192
|
PahoMqtt.logger.debug("New reconnect atempt...") if PahoMqtt.logger?
|
183
193
|
connect
|
184
194
|
if connected?
|
185
195
|
break
|
186
196
|
else
|
187
|
-
sleep
|
197
|
+
sleep RECONNECT_RETRY_TIME
|
188
198
|
end
|
189
199
|
end
|
190
200
|
unless connected?
|
191
201
|
PahoMqtt.logger.error("Reconnection atempt counter is over.(#{RECONNECT_RETRY_TIME} times)") if PahoMqtt.logger?
|
192
202
|
disconnect(false)
|
193
|
-
exit
|
194
203
|
end
|
195
204
|
end
|
196
205
|
end
|
data/lib/paho_mqtt/version.rb
CHANGED
@@ -1,11 +1,7 @@
|
|
1
1
|
require 'paho-mqtt'
|
2
|
-
require 'logger'
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
log.level = Logger::DEBUG
|
7
|
-
|
8
|
-
client = PahoMqtt::Client.new({logger: log})
|
3
|
+
client = PahoMqtt::Client.new()
|
4
|
+
PahoMqtt.logger = 'paho.log'
|
9
5
|
|
10
6
|
client.on_message do |pck|
|
11
7
|
puts "New Message: #{pck.topic}\n>>> #{pck.payload}"
|
data/samples/getting_started.rb
CHANGED
data/samples/test_client.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paho-mqtt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pierre Goudet
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -94,8 +94,8 @@ files:
|
|
94
94
|
- lib/paho_mqtt/subscriber.rb
|
95
95
|
- lib/paho_mqtt/version.rb
|
96
96
|
- paho-mqtt.gemspec
|
97
|
+
- samples/client_blocking(reading).rb
|
97
98
|
- samples/client_blocking(writing).rb
|
98
|
-
- samples/client_blocking.rb
|
99
99
|
- samples/getting_started.rb
|
100
100
|
- samples/test_client.rb
|
101
101
|
homepage: https://github.com/RubyDevInc/paho.mqtt.ruby
|