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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ruby-mqtt3.rb +11 -6
  3. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 68bf5d092ad9497fd2bce86c75325cb00438f89b6bc5cb92f6c0ae2221f9e379
4
- data.tar.gz: f7fe2882e4e2fe44013ed4e235dbdebdb892fcd28351d112708e00214abef7d5
3
+ metadata.gz: bf4fecfb1b300b770fb8a8cfe9477270e225d485cb5c51e73c34583f9321e116
4
+ data.tar.gz: 851e771ca32a9594e59f31e8fb5d9ce3bcbe69f3fc70ba7d222a0c5c1a9afe07
5
5
  SHA512:
6
- metadata.gz: d71f5787b3b639396050432b001220f4f46571aea8af362673c2c6f3fdf1d82e382b40a1534c08907610f18f3a7a652885c44a5863d5edfac5c28b81e9e4f344
7
- data.tar.gz: fe9545a26a3135d7e8ab0ceb91c62bf0ae2d7189600b0fa5c04a58dd0405a86171b63301bff9d670b85ecc9954b2da133704091f22615a6d502f0ebfb2743a5d
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 = "\x42\x02".force_encoding('ASCII-8BIT') #PUBACK
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 = "\x52\x02".force_encoding('ASCII-8BIT') #PUBREC
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 = "\x62\x02".force_encoding('ASCII-8BIT') #PUBREL
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 = "\x72\x02".force_encoding('ASCII-8BIT') #PUBCOMP
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 Mqtt3NormalExitException
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
- while @reconnect do
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.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 00:00:00.000000000 Z
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: '0'
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.15
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