simplepubsub 1.0.0 → 1.0.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/lib/simplepubsub.rb +21 -5
- data.tar.gz.sig +0 -0
- metadata +2 -2
- 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: 7a2ebdb4745d554e759c762bec5a725dc9133bd5
|
4
|
+
data.tar.gz: 5345a4d9741104cc47a2f17c8ca94e19d8e76057
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
-
#
|
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.
|
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-
|
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
|