sps-sub 0.3.3 → 0.3.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c756be9c21402d660cd89f8c88970ad88f59ae26
4
- data.tar.gz: 6906bb26289d90da811defc860f7bcddf97fe9f2
3
+ metadata.gz: 8d52f56bc416cad1645e9daebc0d9719ca7cf621
4
+ data.tar.gz: db3cdf09db9a9f478d460d4586c5b4e303f123a0
5
5
  SHA512:
6
- metadata.gz: dc35c4999c5452b8e8247b4a67df1263c8b00c2d7d6ee8a7b5d94dd64a4657e5a7439d61fccac468528d44eb8b56089b2b93e43c66377caad0f6d07c16ec2524
7
- data.tar.gz: ce987dd621986b8b37e18bc55e769319be06cc94f8942716781bc791a874bbefe4af02713c3ff100953aea4559cb2e0003be75ced37f0e2f2dfa149cf5e3e3cf
6
+ metadata.gz: 95f8b9642dfb34eedb057d23e1b4a005a4b9138ce4e5a0e9c8e9029d4e91684bd3b3a48bbb53c11bd7b2463fa6a2f882447711c42f5af45957e96d1ba3c0c75b
7
+ data.tar.gz: 6865ba029b52186bead910b3e57a3d852259962f6ba368229a836a1d11824ce9249ba9c88a8907ce4deb2bad009b24a515681e361299caa36a1b463c97f9da78
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -12,6 +12,7 @@ class SPSSub
12
12
  @host = host || address || 'localhost'
13
13
  @port = port.to_s
14
14
  @callback = callback
15
+ @retry_interval = 1
15
16
 
16
17
  # Trap ^C
17
18
  Signal.trap("INT") {
@@ -28,10 +29,15 @@ class SPSSub
28
29
 
29
30
  end
30
31
 
31
-
32
+ def notice(s)
33
+
34
+ EventMachine.next_tick do
35
+ @ws.send s
36
+ end
37
+
38
+ end
32
39
 
33
40
  def subscribe(topic: '#', &blk)
34
-
35
41
 
36
42
  @t = Time.now
37
43
 
@@ -47,7 +53,7 @@ class SPSSub
47
53
 
48
54
  address = host + ':' + port
49
55
 
50
- ws = WebSocket::EventMachine::Client.connect(:uri => 'ws://' + address)
56
+ @ws = ws = WebSocket::EventMachine::Client.connect(:uri => 'ws://' + address)
51
57
 
52
58
  ws.onopen do
53
59
  puts "Connected"
@@ -76,8 +82,12 @@ class SPSSub
76
82
  puts "Disconnected"
77
83
 
78
84
  return if @status == :quit
79
- sleep 2
80
- puts 'retrying to connect ... '
85
+
86
+ @retry_interval *= 2
87
+ sleep @retry_interval
88
+ @retry_interval = 1 if @retry_interval > 30
89
+
90
+ puts "retrying to connect to #{@host}:#{@port}... "
81
91
  client.em_connect topic
82
92
  end
83
93
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sps-sub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -31,7 +31,7 @@ cert_chain:
31
31
  eWXz4xiizWWSrPuPJABF8HbFYS84edVCuWiEBU5ZWKNpKrx22oDT1PoyBa5tSK6G
32
32
  GFAzdFN+JAj2mQ==
33
33
  -----END CERTIFICATE-----
34
- date: 2016-11-27 00:00:00.000000000 Z
34
+ date: 2017-02-04 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: websocket-eventmachine-client
@@ -54,7 +54,7 @@ dependencies:
54
54
  - !ruby/object:Gem::Version
55
55
  version: 1.1.0
56
56
  description:
57
- email: james@r0bertson.co.uk
57
+ email: james@jamesrobertson.eu
58
58
  executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
@@ -80,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
80
80
  version: '0'
81
81
  requirements: []
82
82
  rubyforge_project:
83
- rubygems_version: 2.5.1
83
+ rubygems_version: 2.6.8
84
84
  signing_key:
85
85
  specification_version: 4
86
86
  summary: Subscribes to a SimplePubsub (SPS) broker
metadata.gz.sig CHANGED
Binary file