simplepubsub 1.0.0 → 1.0.1

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: d900a96af9a7e45304f1cf25193a619b6a09ea69
4
- data.tar.gz: 074182bcf709b23c432b45a1298f17d7eee8433f
3
+ metadata.gz: 7a2ebdb4745d554e759c762bec5a725dc9133bd5
4
+ data.tar.gz: 5345a4d9741104cc47a2f17c8ca94e19d8e76057
5
5
  SHA512:
6
- metadata.gz: 43fcd46034de9636033bf24ae6e40746201d547f8582b80d2f02232f112ba202c5701768b51787220525293505ed7d7d4979ff29e0ba2a466e2dadbee2c56369
7
- data.tar.gz: 316b94f9395578f798b72eabc7a7aedf4aac58e18e8d9bfdd7a29db835af04bba166ed95f205a90380988ac26bb4de0fda566681dec31df764ca4d4bb8ebfe0a
6
+ metadata.gz: 39e3993b0ea25c2ef5122216963b8c867771f9dee266933733c6ca37cd9a1bec645ef6a6e9143084f4398c90aefd2f2d88e07c82a91c32fe622bd7393c5b1cb6
7
+ data.tar.gz: 74b44f7215feea756bede94891f4f1727f01e189a0f34b04a91aa3bb5eacdd1210d5d45c1448859487e70d53d7042d373e5b150fbd0be6c315b8b17ef83d07a1
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/simplepubsub.rb CHANGED
@@ -33,7 +33,7 @@ module SimplePubSub
33
33
 
34
34
  if a.first == 'subscribe to topic' then
35
35
 
36
- topic = a.last
36
+ topic = a.last.rstrip
37
37
  subscribers[topic] ||= []
38
38
  subscribers[topic] << ws
39
39
 
@@ -46,12 +46,13 @@ module SimplePubSub
46
46
 
47
47
  connections = subscribers[topic]
48
48
  connections += subscribers['#'] if subscribers['#']
49
- connections.each {|c| c.send message }
49
+ connections.each {|c| c.send topic + ': ' + message }
50
50
  end
51
51
 
52
+ ws.send msg, :type => type
53
+
52
54
  end
53
55
 
54
- ws.send msg, :type => type
55
56
  end
56
57
 
57
58
  ws.onclose do
@@ -99,7 +100,7 @@ module SimplePubSub
99
100
 
100
101
  ws.onmessage do |msg, type|
101
102
 
102
- a = msg.split(/\s*,\s*/,2)
103
+ a = msg.split(/\s*:\s*/,2)
103
104
  topic, message = a
104
105
  r = pubsub.proc.call topic, message
105
106
  (ws.close; EM.stop) if r == :stop
@@ -121,7 +122,22 @@ end
121
122
 
122
123
  if __FILE__ == $0 then
123
124
 
124
- # Subscribe example
125
+ # Server example
125
126
  SimplePubSub::Server.new.start
126
127
 
128
+ =begin
129
+
130
+ # Subscribe example
131
+ SimplePubSub::Client.connect('localhost') do |client|
132
+ client.get('test') do |topic, message|
133
+ puts "#{topic}: #{message}"
134
+ end
135
+ end
136
+
137
+ # Publish example
138
+ SimplePubSub::Client.connect('localhost') do |client|
139
+ client.publish('test', Time.now.to_s)
140
+ end
141
+
142
+ =end
127
143
  end
data.tar.gz.sig CHANGED
Binary file
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.0
4
+ version: 1.0.1
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-10 00:00:00.000000000 Z
34
+ date: 2013-11-11 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: websocket-eventmachine-server
metadata.gz.sig CHANGED
Binary file