ruby-mqtt3 1.0.0 → 1.0.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.
- checksums.yaml +4 -4
- data/lib/ruby-mqtt3.rb +11 -6
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf4fecfb1b300b770fb8a8cfe9477270e225d485cb5c51e73c34583f9321e116
|
4
|
+
data.tar.gz: 851e771ca32a9594e59f31e8fb5d9ce3bcbe69f3fc70ba7d222a0c5c1a9afe07
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f22d1ceca6e946b08bae7b79f8257b291db2d6f3f44e611c9e7c7fb38ea8a8b96f08ca17d682c36032676fbabecd4b55732c73974e8aa0fe191dba26834f7f27
|
7
|
+
data.tar.gz: c9ccf312d52c591ce6a8cce6bede49a2e57880d7c2bc348ed2704eadf3bfdbaed33cf6d7979251045413ee748864a3ef09d0a06fb2b09373bbcfd3cf43049db9
|
data/lib/ruby-mqtt3.rb
CHANGED
@@ -3,6 +3,9 @@ require 'openssl'
|
|
3
3
|
class Mqtt3NormalExitException < Exception
|
4
4
|
end
|
5
5
|
|
6
|
+
class Mqtt3AbnormalExitException < Exception
|
7
|
+
end
|
8
|
+
|
6
9
|
class Mqtt3
|
7
10
|
attr_accessor :debug
|
8
11
|
|
@@ -229,25 +232,25 @@ class Mqtt3
|
|
229
232
|
end
|
230
233
|
|
231
234
|
def puback(packet_id)
|
232
|
-
packet = "\
|
235
|
+
packet = "\x40\x02".force_encoding('ASCII-8BIT') #PUBACK
|
233
236
|
packet += encode_short(packet_id)
|
234
237
|
send_packet(packet)
|
235
238
|
end
|
236
239
|
|
237
240
|
def pubrec(packet_id)
|
238
|
-
packet = "\
|
241
|
+
packet = "\x50\x02".force_encoding('ASCII-8BIT') #PUBREC
|
239
242
|
packet += encode_short(packet_id)
|
240
243
|
send_packet(packet)
|
241
244
|
end
|
242
245
|
|
243
246
|
def pubrel(packet_id)
|
244
|
-
packet = "\
|
247
|
+
packet = "\x60\x02".force_encoding('ASCII-8BIT') #PUBREL
|
245
248
|
packet += encode_short(packet_id)
|
246
249
|
send_packet(packet)
|
247
250
|
end
|
248
251
|
|
249
252
|
def pubcomp(packet_id)
|
250
|
-
packet = "\
|
253
|
+
packet = "\x70\x02".force_encoding('ASCII-8BIT') #PUBCOMP
|
251
254
|
packet += encode_short(packet_id)
|
252
255
|
send_packet(packet)
|
253
256
|
end
|
@@ -488,7 +491,7 @@ class Mqtt3
|
|
488
491
|
#TODO rescue
|
489
492
|
chunk = @socket.read(count - buffer.length)
|
490
493
|
if chunk == '' || chunk.nil?
|
491
|
-
raise
|
494
|
+
raise Mqtt3AbnormalExitException
|
492
495
|
else
|
493
496
|
buffer += chunk
|
494
497
|
end
|
@@ -540,7 +543,7 @@ class Mqtt3
|
|
540
543
|
@fiber_main = Fiber.current
|
541
544
|
#debug 'entering main fiber' + @fiber_main.inspect
|
542
545
|
counter = 0
|
543
|
-
|
546
|
+
loop do
|
544
547
|
ret = tcp_connect()
|
545
548
|
if ret.is_a? (Exception)
|
546
549
|
@on_tcp_connect_error_block.call(e,counter) unless @on_tcp_connect_error_block.nil?
|
@@ -557,6 +560,7 @@ class Mqtt3
|
|
557
560
|
e = read_from_socket_loop()
|
558
561
|
rescue Mqtt3NormalExitException
|
559
562
|
@reconnect = false
|
563
|
+
rescue Mqtt3AbnormalExitException
|
560
564
|
rescue
|
561
565
|
end
|
562
566
|
|
@@ -583,6 +587,7 @@ class Mqtt3
|
|
583
587
|
end
|
584
588
|
end
|
585
589
|
end
|
590
|
+
break unless @reconnect
|
586
591
|
end
|
587
592
|
#debug 'exiting main fiber' + @fiber_main.inspect
|
588
593
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-mqtt3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jsaak
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-05-
|
11
|
+
date: 2022-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Using Fibers and Fiber.scheduler, so needs ruby 3
|
14
14
|
email: fake@fake.com
|
@@ -29,14 +29,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
29
29
|
requirements:
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
32
|
+
version: '3'
|
33
33
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
34
|
requirements:
|
35
35
|
- - ">="
|
36
36
|
- !ruby/object:Gem::Version
|
37
37
|
version: '0'
|
38
38
|
requirements: []
|
39
|
-
rubygems_version: 3.2.
|
39
|
+
rubygems_version: 3.2.22
|
40
40
|
signing_key:
|
41
41
|
specification_version: 4
|
42
42
|
summary: Ruby implementation of MQTT 3.1.1 protocol
|