simplepubsub 1.0.2 → 1.0.3
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 +1 -1
- data.tar.gz.sig +2 -3
- data/lib/simplepubsub.rb +16 -12
- metadata +2 -2
- metadata.gz.sig +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0375d7b69444d6c22a7ce555ed8009af1d837eb
|
4
|
+
data.tar.gz: f1ab4dc41fcfa2bf7db9dce8223c4f26755b53f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 112e3b99b33bebb463961e5299df7e12b4f807eaa403b4e1a79657eb24c1f67acd1d75daef826c26475a59189268d9d1a83e78c2959c10e4dccea573bea2f7b4
|
7
|
+
data.tar.gz: cbfd16c7036aa3325b475cf7784e19710aff59c89dddc886a2d77b40d8a6690daa9d4ca23ff31caec0bba03c64c77f1ef8ab24bbd9eb07285f26c503b7d9a6e6
|
checksums.yaml.gz.sig
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
�h����"Қ�w�4������~6e���)à����V[��Rs`Eg������L({P0��`r�n�Ǫ����Na�1jWt��Delu�����/Mi��Gȸb)������DYZ��~���
|
data.tar.gz.sig
CHANGED
@@ -1,3 +1 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
�F9^Iv�B���
|
1
|
+
Y�8���(�8V�SG �[��̎}�1��EG��<(�XM��a�/�~�+
|
2
|
+
/���u��cW֭u�g�v�2*�"��&~����<"M
|
data/lib/simplepubsub.rb
CHANGED
@@ -41,23 +41,25 @@ module SimplePubSub
|
|
41
41
|
subscribers[topic] ||= []
|
42
42
|
subscribers[topic] << ws
|
43
43
|
|
44
|
-
def ws.
|
45
|
-
|
46
|
-
|
44
|
+
def ws.subscriber_topic=(topic) @topic = topic end
|
45
|
+
def ws.subscriber_topic() @topic end
|
46
|
+
|
47
|
+
ws.subscriber_topic = topic
|
47
48
|
|
48
49
|
elsif a.length > 1
|
49
50
|
|
50
51
|
puts "publish this %s: %s" % a
|
51
52
|
topic, message = a
|
52
53
|
|
53
|
-
if subscribers[topic]
|
54
|
+
if subscribers[topic] then
|
55
|
+
subscribers[topic].each {|c| c.send topic + ': ' + message }
|
56
|
+
end
|
54
57
|
|
55
|
-
|
56
|
-
|
57
|
-
connections.each {|c| c.send topic + ': ' + message }
|
58
|
+
if subscribers['#'] then
|
59
|
+
subscribers['#'].each {|c| c.send topic + ': ' + message }
|
58
60
|
end
|
59
61
|
|
60
|
-
ws.send msg, :type => type
|
62
|
+
#ws.send msg, :type => type
|
61
63
|
|
62
64
|
end
|
63
65
|
|
@@ -65,7 +67,9 @@ module SimplePubSub
|
|
65
67
|
|
66
68
|
ws.onclose do
|
67
69
|
puts "Client disconnected"
|
68
|
-
|
70
|
+
if ws.respond_to? :subscriber_topic then
|
71
|
+
subscribers[ws.subscriber_topic].delete ws
|
72
|
+
end
|
69
73
|
end
|
70
74
|
end
|
71
75
|
|
@@ -97,7 +101,7 @@ module SimplePubSub
|
|
97
101
|
pubsub = PubSub.new
|
98
102
|
yield(pubsub)
|
99
103
|
|
100
|
-
blk = lambda do |ws, em_already_running|
|
104
|
+
blk = lambda do |ws, pubsub, em_already_running|
|
101
105
|
|
102
106
|
ws.onopen do
|
103
107
|
puts "Connected"
|
@@ -130,12 +134,12 @@ module SimplePubSub
|
|
130
134
|
# attempt to run a websocket assuming the EventMachine is
|
131
135
|
# already running
|
132
136
|
ws = c.connect(params)
|
133
|
-
blk.call ws, em_already_running = true
|
137
|
+
blk.call ws, pubsub, em_already_running = true
|
134
138
|
rescue
|
135
139
|
|
136
140
|
EM.run do
|
137
141
|
ws = c.connect(params)
|
138
|
-
blk.call(ws, em_already_running = false)
|
142
|
+
blk.call(ws, pubsub, em_already_running = false)
|
139
143
|
end
|
140
144
|
end
|
141
145
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simplepubsub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
i0PBE6fLwlIMk8jNNUcX3J1csSMgLNTwE8CwrlSZE8sueHj0pQzICM7lF0gGREO6
|
32
32
|
hQHD0LljU3MusQ==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2013-11-
|
34
|
+
date: 2013-11-15 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: websocket-eventmachine-server
|
metadata.gz.sig
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
�G_��u!�7U35ԍN�YZÇ!��c��hysҢ�Q��@����9�l$�� �<Ε�7:Qp�U��gr��x{����n֓u�����`�PS�{���������GM����F��aU�{���(�`.�ťdO��ͺ�.�A�@�rm���}?�px�Մ=�Zu�W�_�g���܅T�a��L��r�t�31n�b��C+�F��4 ��g��m���� ,oK-�����"�I��2B5��Lb�R��
|