mqtt-sub_handler 0.1.6.4 → 0.1.6.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: d3eef659ff2c5da99d386d05fc145c328d7eea5b2057d30fa7f1ec43bda7748c
4
- data.tar.gz: 69559fc70301f60f25ea322731b936738eb7d55609a8c817fcedf161e3640590
2
+ SHA1:
3
+ metadata.gz: 1b63292ef3dbfdfb64cd76e98da11ea6b23c916c
4
+ data.tar.gz: 1db5486954346b4f8e09bc807a95b4e578ceac77
5
5
  SHA512:
6
- metadata.gz: 1693df3d20154bb9a283cd75f0f3f82411173c7716daa89f84c89a0497ef36fa92965827927baa32ec1ead5c6697e87f3270c10099b7fd3815695be06af730f0
7
- data.tar.gz: cc4fab89804258ffdbec5d89a11a94426c264b2866f10780cfff4aab3422cb78ca031b784e0e0200b20815f3ffc27934740b9250c8a0ef1283779bcbc05a0206
6
+ metadata.gz: 527c14a9c9c9fd67c7d93607b5bed6ee7bf4b8f29145c52ff2829bb2fea903a2ca1fe089234c7471ce538b9d6513367042028fecb1fab7c397dfe43ddc960ec3
7
+ data.tar.gz: 1ac7f34fe0adeef751bddbc568fad12160eec2c71c4d449791b041091b4c1855429976d1942a327aa43bd9b513386c994c73e80e319e483f1dfbf786b6380220
@@ -62,10 +62,10 @@ module MQTT
62
62
  h.offer(tMatch, data)
63
63
  }
64
64
  rescue Timeout::Error
65
- x_logf("Timeout on callback #{h}");
65
+ x_loge("Timeout on callback #{h}");
66
66
  rescue => e
67
67
  x_logf("Uncaught error on #{h}");
68
- x_logf(e);
68
+ x_logf(e.inspect);
69
69
  end
70
70
  topicHasReceivers = true;
71
71
  end
@@ -82,7 +82,7 @@ module MQTT
82
82
  @packetQueueMutex.synchronize {
83
83
  @packetQueue << data;
84
84
  if(@packetQueue.size == 999)
85
- x_loge("Packet queue congested, dropping packets!");
85
+ x_logf("Packet queue congested, dropping packets!");
86
86
  end
87
87
  if(@packetQueue.size > 1000)
88
88
  @packetQueue.shift
@@ -196,7 +196,7 @@ module MQTT
196
196
  end
197
197
  rescue MQTT::Exception, SocketError, SystemCallError, Timeout::Error => e
198
198
  x_loge("Push error!");
199
- x_loge(e.inspet);
199
+ x_loge(e.inspect);
200
200
 
201
201
  sleep 0.5
202
202
  end
@@ -218,6 +218,7 @@ module MQTT
218
218
  x_logi("Connected!");
219
219
  @conChangeMutex.synchronize {
220
220
  @connected = true;
221
+ @reconnectCount = 0;
221
222
  }
222
223
 
223
224
  @packetQueueMutex.synchronize {
@@ -231,10 +232,11 @@ module MQTT
231
232
  rescue MQTT::Exception, Timeout::Error, SocketError, SystemCallError
232
233
  x_loge("Disconnected!") if @connected
233
234
  @connected = false;
235
+ @reconnectCount += 1;
234
236
 
235
237
  @conChangeMutex.unlock if @conChangeMutex.owned?
236
238
  @mqtt.clean_session = false;
237
- sleep 2
239
+ sleep [0.1, 0.5, 1, 1, 5, 5, 5, 10, 10, 10, 10][@reconnectCount] || 30;
238
240
  end
239
241
  end
240
242
 
@@ -242,18 +244,6 @@ module MQTT
242
244
  end
243
245
  private :mqtt_resub_thread
244
246
 
245
- # Pause the main thread and wait for messages.
246
- # This is mainly useful when the code has set everything up, but doesn't just want to end.
247
- # "INT" is trapped, ensuring a smooth exit on Ctrl-C
248
- def lockAndListen()
249
- Signal.trap("INT") {
250
- exit 0
251
- }
252
-
253
- puts "Main thread paused."
254
- Thread.stop();
255
- end
256
-
257
247
  def destroy!()
258
248
  return if @destroying
259
249
  @destroying = true;
@@ -268,7 +258,7 @@ module MQTT
268
258
  end
269
259
  }
270
260
  rescue Timeout::Error
271
- x_logw "Publishes did not complete";
261
+ x_logw "Not all messages were published";
272
262
  else
273
263
  x_logd "Publish clean finished"
274
264
  end
@@ -308,7 +298,8 @@ module MQTT
308
298
  self.log_level = Logger::INFO;
309
299
 
310
300
  @conChangeMutex = Mutex.new();
311
- @connected = false;
301
+ @connected = false;
302
+ @reconnectCount = 0;
312
303
 
313
304
  @mqtt.client_id ||= MQTT::Client.generate_client_id("MQTT_Sub_", 8);
314
305
 
@@ -124,6 +124,19 @@ class SubHandler < BaseHandler
124
124
  end
125
125
  alias publishTo publish_to
126
126
 
127
+ # Pause the main thread and wait for messages.
128
+ # This is mainly useful when the code has set everything up, but doesn't just want to end.
129
+ # "INT" is trapped, ensuring a smooth exit on Ctrl-C
130
+ def lockAndListen()
131
+ Signal.trap("INT") {
132
+ exit 0
133
+ }
134
+
135
+ x_logi("Main thread paused.")
136
+ Thread.stop();
137
+ end
138
+ alias lock_and_listen lockAndListen
139
+
127
140
  def initialize(mqttClient, jsonify: true)
128
141
  super(mqttClient);
129
142
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mqtt-sub_handler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6.4
4
+ version: 0.1.6.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Xasin
@@ -129,7 +129,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
129
  - !ruby/object:Gem::Version
130
130
  version: '0'
131
131
  requirements: []
132
- rubygems_version: 3.0.6
132
+ rubyforge_project:
133
+ rubygems_version: 2.5.2.1
133
134
  signing_key:
134
135
  specification_version: 4
135
136
  summary: Asynchronous, topic-based MQTT gem