mqtt-sub_handler 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/mqtt/sub_handler.rb +15 -3
  3. metadata +15 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8d47218ce7ba4ae48cf8b7b44ecd807889111f520a86d5eaa5d458590d75ee5b
4
- data.tar.gz: ba2fdf1f66a85f0de62c8c3b0238aa8ddf43df4a8e396440df92daf3323286ee
3
+ metadata.gz: 22d57768280da99134fc12c1ab6d07b441df823f59992d88411a1bc8b88cfe16
4
+ data.tar.gz: 34ead01f1186b52591969071404c2812badd339e17a404178b44295d6d6ed8e8
5
5
  SHA512:
6
- metadata.gz: 44c1ab1959a9d930ff9ffa18ee5f665d0ac76ae66da132c57dc12ccba36f7228b759d1b3eb24986b40160c2376569d33129ef127433a15f5f1aec6a3af5c4e2e
7
- data.tar.gz: 609f907b547a2a78a08a2f2cdcf1f241cc2db70f8dc17c124682aac3423375f1f55399bfc2a376582fcd93fbc2fcf7d7648768d2bd14ad3c03878e5d671326c5
6
+ metadata.gz: 11569eef332d8d8c186b6c246bfd32bea0643270152e27c06b1e92e560c93a091809a2994c3424fd36ed9e0d2898defcc8f45e7e57da3879a276e837d6e2b663
7
+ data.tar.gz: a1d962a3af87a942f45af28540b5902903cf0e37a569d7b174793dd471183c8337fc95f1bd4f0a06a9b9997cb04da78e60ed663be399968bddced5e641ad0aad
@@ -3,6 +3,8 @@ require 'timeout'
3
3
  require 'mqtt'
4
4
  require 'json'
5
5
 
6
+ require 'colorize'
7
+
6
8
  require_relative 'subscription_classes.rb'
7
9
 
8
10
  # @author Xasin
@@ -294,7 +296,7 @@ class SubHandler
294
296
  Timeout.timeout(4) {
295
297
  @mqtt.connect()
296
298
  }
297
- STDERR.puts("MQTT #{@mqtt.host} connected!")
299
+ STDERR.puts("MQTT: #{@mqtt.host} connected!".green)
298
300
  @conChangeMutex.synchronize {
299
301
  @connected = true;
300
302
  }
@@ -303,7 +305,7 @@ class SubHandler
303
305
  call_interested(topic, message);
304
306
  end
305
307
  rescue MQTT::Exception, Timeout::Error, SocketError, SystemCallError
306
- STDERR.puts("MQTT #{@mqtt.host} disconnected!");
308
+ STDERR.puts("MQTT #{@mqtt.host} disconnected!".red);
307
309
  @connected = false;
308
310
 
309
311
  @conChangeMutex.unlock if @conChangeMutex.owned?
@@ -329,7 +331,7 @@ class SubHandler
329
331
  unless @publishQueue.empty?
330
332
  print "Finishing sending of MQTT messages ... "
331
333
  begin
332
- Timeout.timeout(10) {
334
+ Timeout.timeout(4) {
333
335
  until @publishQueue.empty? do
334
336
  sleep 0.05;
335
337
  end
@@ -385,6 +387,16 @@ class SubHandler
385
387
  end
386
388
  @publisherThread.abort_on_exception = true;
387
389
 
390
+ begin
391
+ Timeout.timeout(3) {
392
+ until(@connected)
393
+ sleep 0.1;
394
+ end
395
+ }
396
+ rescue Timeout::Error
397
+ STDERR.puts "MQTT: #{@mqtt.host} did not connect!".red
398
+ end
399
+
388
400
  at_exit {
389
401
  flush_pubqueue();
390
402
  @listenerThread.kill();
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.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Xasin
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: colorize
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: minitest
43
57
  requirement: !ruby/object:Gem::Requirement