sps-sub 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/sps-sub.rb +14 -2
- metadata +1 -1
- 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: 53970659171d8794f9ef9e5678eb5d74bdc0193f
|
4
|
+
data.tar.gz: 005ff79b8a8fe637c191d5a78c2ca655873813eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c90b4b210262a656d9ee82072157da212105474f8b4b5a42cd7af3fbde9c0903351038b5b33e0c5ce8f251f9a0f2115f6e42ec48e7ba9ab18f868bbc6eca1fab
|
7
|
+
data.tar.gz: 7eb490ff1f01e720d5d2a37896658f16836f936467a15d62e4885e15f03895503d211b76492c73a850057dc81717f9830abd5d07d423f6055680073e903ee7dd
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/sps-sub.rb
CHANGED
@@ -29,8 +29,12 @@ class SPSSub
|
|
29
29
|
puts "Connected"
|
30
30
|
end
|
31
31
|
|
32
|
-
ws.onmessage do |
|
32
|
+
ws.onmessage do |fqm, type|
|
33
|
+
|
34
|
+
topic, msg = fqm.split(/:\s+/,2)
|
33
35
|
onmessage msg
|
36
|
+
ontopic topic, msg
|
37
|
+
|
34
38
|
end
|
35
39
|
|
36
40
|
ws.onclose do
|
@@ -44,10 +48,18 @@ class SPSSub
|
|
44
48
|
end
|
45
49
|
end
|
46
50
|
|
51
|
+
# This method is called when a new message is received
|
52
|
+
#
|
47
53
|
def onmessage(msg)
|
48
54
|
puts "Received message: #{msg}"
|
49
55
|
end
|
56
|
+
|
57
|
+
# Same as onmessage but includes the topic as well as the msg
|
58
|
+
#
|
59
|
+
def ontopic(topic, msg)
|
50
60
|
|
61
|
+
end
|
62
|
+
|
51
63
|
end
|
52
64
|
|
53
65
|
if __FILE__ == $0 then
|
@@ -60,4 +72,4 @@ if __FILE__ == $0 then
|
|
60
72
|
|
61
73
|
sps.subscribe topic: 'test'
|
62
74
|
|
63
|
-
end
|
75
|
+
end
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|