sps-sub 0.2.1 → 0.3.0
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
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/sps-sub.rb +17 -3
- metadata +3 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 39750eb62d235a942c3a81782d28a5785f25f583
|
|
4
|
+
data.tar.gz: afdd7d8e1b6347249760593bde56ae32401dd8e0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 603a63b35aef26e06a9f4348dff94a72ba9080674c217289ca24102efa5c0f3f1c324afe8d5b3b264eccfb756b8e8ccd937bf96bf79ab8afe11d312d3e33979d
|
|
7
|
+
data.tar.gz: d4836e1e2a176159038b6f4126d2ffe6544276ba79cf012938b1c6e32fec15926504c62e4658dff557291d7133b7cfec99488e40a349cca0301ef3f3a048e22d
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data.tar.gz.sig
CHANGED
|
Binary file
|
data/lib/sps-sub.rb
CHANGED
|
@@ -12,13 +12,21 @@ class SPSSub
|
|
|
12
12
|
@host = host || address || 'localhost'
|
|
13
13
|
@port = port.to_s
|
|
14
14
|
@callback = callback
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
def subscribe(topic: nil, &blk)
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
|
|
21
|
+
@t = Time.now
|
|
21
22
|
|
|
23
|
+
em_connect(topic, &blk)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def em_connect(topic, &blk)
|
|
27
|
+
|
|
28
|
+
host, port = @host, @port
|
|
29
|
+
|
|
22
30
|
EM.run do
|
|
23
31
|
|
|
24
32
|
address = host + ':' + port
|
|
@@ -50,13 +58,19 @@ class SPSSub
|
|
|
50
58
|
|
|
51
59
|
ws.onclose do
|
|
52
60
|
puts "Disconnected"
|
|
61
|
+
sleep 2
|
|
62
|
+
puts 'retrying to connect ... '; em_connect topic if @t + 5 > Time.now
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
ws.onerror do |error|
|
|
66
|
+
puts "Error occured: #{error}"
|
|
53
67
|
end
|
|
54
68
|
|
|
55
69
|
EventMachine.next_tick do
|
|
56
70
|
ws.send 'subscribe to topic: ' + topic
|
|
57
71
|
end
|
|
58
72
|
|
|
59
|
-
end
|
|
73
|
+
end
|
|
60
74
|
end
|
|
61
75
|
|
|
62
76
|
# This method is called when a new message is received
|
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.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- James Robertson
|
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
|
31
31
|
fHBa0yvyttUJ9MAHDdNAqgELoWyqVM9yRbtQyngMXb+uCVGFMhfM9IkfaGEPDY7M
|
|
32
32
|
B2N6m1GaxGXUJQ==
|
|
33
33
|
-----END CERTIFICATE-----
|
|
34
|
-
date: 2015-
|
|
34
|
+
date: 2015-08-08 00:00:00.000000000 Z
|
|
35
35
|
dependencies:
|
|
36
36
|
- !ruby/object:Gem::Dependency
|
|
37
37
|
name: websocket-eventmachine-client
|
|
@@ -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.4.
|
|
83
|
+
rubygems_version: 2.4.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
|