simplepubsub 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6c6e71936113e7c6809d833f169db2c7c7650df5
4
- data.tar.gz: d6f910581d9eec557b010b5e143663eae7104f6e
3
+ metadata.gz: e0375d7b69444d6c22a7ce555ed8009af1d837eb
4
+ data.tar.gz: f1ab4dc41fcfa2bf7db9dce8223c4f26755b53f0
5
5
  SHA512:
6
- metadata.gz: 2ab5350b0ffd45933731bc231baa24569d7d8f25fbad9d6d18adaf70ee19bc10ecd6b8b53100ef5cfcc2685660086340ff60741b637a37e809eae7e1bcd4a231
7
- data.tar.gz: eb9f27007292a36c67937939db5b268b88e8ef428d6b73713c1ac4520495df4b34cf4d28bd522c8167d1f0aa8d76353f26b4f4f086f18e733a0184fe3d41af77
6
+ metadata.gz: 112e3b99b33bebb463961e5299df7e12b4f807eaa403b4e1a79657eb24c1f67acd1d75daef826c26475a59189268d9d1a83e78c2959c10e4dccea573bea2f7b4
7
+ data.tar.gz: cbfd16c7036aa3325b475cf7784e19710aff59c89dddc886a2d77b40d8a6690daa9d4ca23ff31caec0bba03c64c77f1ef8ab24bbd9eb07285f26c503b7d9a6e6
checksums.yaml.gz.sig CHANGED
@@ -1 +1 @@
1
- �� v�z�%\A�!��#F��)jH`��rr�b���D3X@�<`��䫇��5�fW�����؆n߶)��&a��=�OF�R�SA稥��TЙ��o�8]?~�æ�R" o_��#�Il�E�����9��W8p���(Ju;�=��ahx��m�#
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
- !��UT�!c&�\^��F/�9y0�׌�#<8S��}u T��X����˄��������Z�`qD����k
2
- 0V�ȑ�G>�aExgV��Nj͸�!�7K&KZ&Ww���#�xN��
3
- �F9^Iv�B���
1
+ Y 8���(�8V�SG �[��̎}�1��EG��<(�XM��a�/�~�+
2
+ /���u��cW֭ugv2*�"��&~����<"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.subscriber?()
45
- true
46
- end
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] and subscribers[topic].any? then
54
+ if subscribers[topic] then
55
+ subscribers[topic].each {|c| c.send topic + ': ' + message }
56
+ end
54
57
 
55
- connections = subscribers[topic]
56
- connections += subscribers['#'] if subscribers['#']
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
- subscribers[topic].delete ws if ws.subscriber?
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.2
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-11 00:00:00.000000000 Z
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
- TOL��f����di?�#%���s�q{ݯ+���Y��;�iRip;�'����,������u��g:D꓁{wW�
1
+ G_��u!�7U35ԍNYZÇ!؜��c��hysҢ�Q��@����9�l$�� �<Ε�7:Qp�U��gr��x{����n֓u �����`�PS{���������GM����F��a U�{���(�`.�ťdO��ͺ�.�A�@�rm���}?�px�Մ=�Zu�W�_�g���܅T�a��L��r�t�31n�b��C+�F��4 ��g��m���� , oK-���‘��"�I��2B5��Lb�R��